Created
March 5, 2020 23:51
-
-
Save mfp22/3d9a6a7695c31d031db95871ffc978cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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