我不会使用$ index来创建新的$ scope变量:

    <div ng-repeat="i in items track by $index">
            <input autocomplete="off" type="text"
             ng-model="myVariableName{{$index}}" >
            ....


我不会声明变量:myVariableName0,myVariableName1等。

最佳答案

在控制器中声明空对象

$scope.myVariableName = {};


并在模板中将模型值分配为对象的属性。

ng-model="myVariableName[$index]"

10-04 21:25