我有一个输入字段的表,我在ng-repeat
的每次迭代设置值为ng-model
。我在每次迭代中都得到了正确的值,但所有ng-model
值都会被最后一次迭代值覆盖。我该如何解决这个问题?吴重复ng-model重写
视图
<tr ng-repeat="student in students_list">
<td>{{student.Rollnumber}}</td>
<td>{{student.Name}}</td>
<td ng-repeat="item in Allsubjects" >
<input type="text" class="form-control" ng-model="da"
ng-init="alert(student.Id)">
</td>
</tr>
控制器
$scope.alert = function(id)
{
$scope.da =id;
};
这是我收到(截图):
331是最后一次迭代的结果。它覆盖了以前的值。
它应该有不同的模型。像这样'ng-model =“item.da”' –
@Hadi你能解释一下吗?我是一个小菜 –
请分享'Allsubjects'对象 –