Created
March 5, 2020 23:46
-
-
Save mfp22/a4a3d43ebe3665697a7361e9f32a20f4 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'; | |
@Directive({ | |
selector: '[disableFormGroup]', | |
}) | |
export class DisableFormGroupDirective { | |
@Input() form: any; | |
@Input() formGroupName: string; | |
@Input() | |
set disableFormGroup(disabled: boolean) { | |
const method = disabled ? 'disable' : 'enable'; | |
this.form.get(this.formGroupName)[method](); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment