<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>
Run Code Online (Sandbox Code Playgroud)
什么是使用ng-model和ng-control的差异?什么时候使用它们?
ngControl、ngModel和ngFormControl是NgControlStatus指令的选择器,所以它们之间没有区别......
NgControlStatus 是自动应用于 Angular 表单的指令,它根据控件状态(有效/无效/脏/等)设置 CSS 类。
NgFormControl是将模板中的输入字段绑定到Control用于以编程方式创建表单字段的类的指令。
NgFormControl将现有控件绑定到 DOM 元素。
| 归档时间: |
|
| 查看次数: |
3860 次 |
| 最近记录: |