我有一个简单的表格(从实际表格中删除以证明问题):
<pre>Name: {{currentChild.name}}</pre>
<pre>Annual College Expense: {{currentChild.annualCollegeExpense}}</pre>
<form name="childForm" novalidate>
<div class="form-inline">
<div class="form-group">
<label>Name:</label>
<input type="text" name="name" class="form-control" ng-minlength="1" ng-model="currentChild.name" ng-required="true">
<div class="help-block"
ng-messages="childForm.name.$error"
ng-show="childForm.$submitted || childForm.name.$dirty || (childForm.name.$invalid && childForm.name.$touched)">
<p ng-message="required" ng-hide="childForm.name.$valid">Your name is required.</p>
<p ng-message="minlength" ng-hide="childForm.name.$valid">Your name is too short.</p>
</div>
</div>
<div class="form-group">
<label>Annual Expenses:</label>
<input type="text" name="annualCollegeExpense" class="form-control" ngModel="currentChild.annualCollegeExpense" />
</div>
</div>
</form>
当我启动表单时,我在表单顶部的pres中看到了预期的数据。当我输入名称字段时,pre中的名称会更改。当我输入年度费用字段时,年度费用预先不会改变。
由于这些是IDENTICAL并且似乎遵守所有通常的ng模型规则,即使用a。为了引用模型中的数据,我很难过。
有人有建议吗?
答案 0 :(得分:1)
您使用ngModel
代替ng-model
,因此您应该使用
ng-model="currentChild.annualCollegeExpense"
而不是
ngModel="currentChild.annualCollegeExpense"
使用
<input type="text" name="annualCollegeExpense" class="form-control" ng-model="currentChild.annualCollegeExpense" />