嵌套在ng中的Angularjs ng模型重复更新所有
这应该很简单。出于某种原因,当在ng repeat中使用ng模型时,它会更新该repeat循环中的所有ng模型 这是密码。有什么想法吗? 谢谢。很有趣 问题是您正在使用“$scope.columns”中的对象重置row.field 在嵌套在ng中的Angularjs ng模型重复更新所有,angularjs,angularjs-ng-repeat,ng-repeat,angular-ngmodel,Angularjs,Angularjs Ng Repeat,Ng Repeat,Angular Ngmodel,这应该很简单。出于某种原因,当在ng repeat中使用ng模型时,它会更新该repeat循环中的所有ng模型 这是密码。有什么想法吗? 谢谢。很有趣 问题是您正在使用“$scope.columns”中的对象重置row.field 在 在这里,row.field用$scope.columns中的一个对象重置,如果在一行中更改此对象,因为其他行也使用相同的对象,则它们重复相同的值 您可以将此模型更改为row.field.type作为 <td> <select ng-
在这里,row.field用$scope.columns中的一个对象重置,如果在一行中更改此对象,因为其他行也使用相同的对象,则它们重复相同的值
您可以将此模型更改为row.field.type作为
<td>
<select ng-model="row.field.type" ng-options="column.type as column.title for column in columns" ng-change="resetRow(row.field)"></select>
</td>
并在控制器中定义$scope.resetRow
,以根据字段类型重置其他属性
这里是最新的
我想在ng选项中有一个功能来返回
选择的对象而不是对象引用来解决您的问题
<td>
<select ng-model="row.field.type" ng-options="column.type as column.title for column in columns" ng-change="resetRow(row.field)"></select>
</td>