Skip to content

Instantly share code, notes, and snippets.

@mfp22
Created March 5, 2020 23:46
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/a4a3d43ebe3665697a7361e9f32a20f4 to your computer and use it in GitHub Desktop.
Save mfp22/a4a3d43ebe3665697a7361e9f32a20f4 to your computer and use it in GitHub Desktop.
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