据我所知,ng-model设置了分配模型的特定元素的值.鉴于ng-value与ng-model有何不同?
javascript angularjs angularjs-directive angularjs-ng-model angularjs-ng-value
如何在AngularJS中设置输入文本框的默认值,以便以后可以更改?我希望能够将文本框的更改值(使用ng-model)提交给服务器.在这种情况下,使用ng-value设置文本框的初始值是正确的方法吗?
我有一个与客户打交道的Angular 2应用程序和一个弹簧休息后端.客户对象有一个客户类型,也是一个对象,我在客户表单上下拉工作,以便将对象存储为值,但我无法弄清楚如何选择正确的客户类型现有客户已加载到表单中.
<select class="form-control" required [(ngModel)]="customer.customerType" >
<option *ngFor="let ct of customerTypes" [ngValue]="ct">{{ct.customerType}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
在上面的代码段中,如果客户已有客户类型,则下拉列表将不会选择任何值.我记得使用ngOptions解决了angular1的相同问题:
<select ng-model="customer.customerType"
ng-options="customerType.customerType for customerType in customerTypes
track by customerType.customerType" >
</select>
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是,如何复制Angular1在Angular 2中解决这个问题的方式