本文介绍了在angular2中使用ng-model和ng-control之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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的差异黑白是什么?什么时候使用它们?
What is the diff b/w using ng-model and ng-control? When to use each of them?
推荐答案
ngControl
,ngModel
和ngFormControl
是 NgControlStatus
指令,因此它们之间没有区别...
ngControl
, ngModel
and ngFormControl
are selectors for NgControlStatus
directive, so there's no difference between them...
NgFormControl
是绑定输入的指令模板中的 Control
类中的字段用于以编程方式创建表单字段.
NgFormControl
is directive that binds input field in the template to the Control
class that is used to programmatically create form fields.
这篇关于在angular2中使用ng-model和ng-control之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!