Skip to content

Instantly share code, notes, and snippets.

@mfp22
Created March 5, 2020 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfp22/3d9a6a7695c31d031db95871ffc978cf to your computer and use it in GitHub Desktop.
Save mfp22/3d9a6a7695c31d031db95871ffc978cf to your computer and use it in GitHub Desktop.
import {Directive, Input} from '@angular/core';
import {NgControl} from '@angular/forms';
@Directive({
selector: '[disableControl]',
})
export class DisableControlDirective {
@Input()
set disableControl(disabled: boolean) {
const method = disabled ? 'disable' : 'enable';
this.ngControl.control[method]();
}
constructor(private ngControl: NgControl) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment