NgControl注入等效于自定义指令中的表单

时间:2018-08-28 09:29:23

标签: angular

我尝试发出启用/禁用表格的指令。通过执行以下代码,我找到了控制的解决方案:

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>

0 个答案:

没有答案
相关问题