是否可以以角度禁用整个表单(组)而不是分别为每个输入执行此操作?
类似于< input [disabled] =“formNotValid”/>但对于< form>或者< div ngModelGroup ..>?
解决方法
如果你使用ReactiveForms只是写
form: formGroup; this.form.disable();
在ngForm的情况下,你可以这样写’创建plunker
<form #f="ngForm" (ngSubmit)="onSubmit(f)" novalidate> <input name="first" ngModel required #first="ngModel"> <input name="last" ngModel> <button>Submit</button> </form> <button (click)="disable(f)">Disable form</button> disable(f) { f.form.disable() }