2
這應該很簡單。由於某些原因,在ng-repeat中使用ng-model時,它會更新該重複循環內的所有ng-models。Angularjs ng-model內嵌ng-repeat更新全部
這是代碼。有任何想法嗎? http://plnkr.co/edit/iAgrPwwBMilCyeReeLt9?p=info
謝謝。
這應該很簡單。由於某些原因,在ng-repeat中使用ng-model時,它會更新該重複循環內的所有ng-models。Angularjs ng-model內嵌ng-repeat更新全部
這是代碼。有任何想法嗎? http://plnkr.co/edit/iAgrPwwBMilCyeReeLt9?p=info
謝謝。
有趣!
問題是,你是從 「$ scope.columns」
對象重置row.field在
<td>
<select ng-model="row.field" ng-options="column.title for column in columns"></select>
</td>
這裏,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
重置基於字段類型的其他屬性。
這是更新的plunker。
我很想在NG-選項的功能,返回 副本選擇,而不是對象引用的對象,雖然解決您的問題。