<form role="form" #form="form" (ng-submit)="submit(form.value)">
<input type="text" placeholder="Enter your name" ng-control="name">
<input type="text" placeholder="Enter your email" [(ng-model)]="email">
<button>Submit</button>
</form>
使用 ng-model 和 ng-control 的黑白差异是什么?何时使用它们中的每一个?
ngControl
, ngModel
and ngFormControl
是选择器NgControlStatus https://angular.io/docs/ts/latest/api/common/NgControlStatus-directive.html指令,所以它们之间没有区别......
NgControlStatus 是指令自动应用于 Angular 表单,根据控件状态(有效/无效/脏/等)设置 CSS 类。
NgFormControl https://angular.io/docs/ts/latest/api/common/NgFormControl-directive.html是将模板中的输入字段绑定到Control https://angular.io/docs/ts/latest/api/common/Control-class.html用于以编程方式创建表单字段的类。
NgForm控件将现有 Control 绑定到 DOM 元素。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)