我尝试发出启用/禁用表格的指令。通过执行以下代码,我找到了控制的解决方案:
export class DisableControlDirective {
@Input() set appDisableControl(condition) {
const action = condition ? 'disable' : 'enable';
this.ngControl.control[action]();
}
constructor(private ngControl: NgControl) { }
}
是否存在等效于NgControl注入的访问FormGroup的权限?
<form
[formGroup]="group" <!-- Access to this -->
[appDisableGroup]="!isEditable" <!-- From this -->
></form>