Javascript 如何在范围索引中传递动态值
我有这样一个ng模型:Javascript 如何在范围索引中传递动态值,javascript,angularjs,Javascript,Angularjs,我有这样一个ng模型: <tr ng-repeat="user in users"> <input type="text" ng-model="code[user.id]"/> 那就不行了 所以我的问题是,如何在{}中传递动态值。像这样赋值 var index = 0; $scope.code = {}; $scope.code[index] = 'value'; 演示 角度模块(“应用程序”,[]) .controller(“ctrl”,函数($scope)
<tr ng-repeat="user in users">
<input type="text" ng-model="code[user.id]"/>
那就不行了
所以我的问题是,如何在{}中传递动态值。像这样赋值
var index = 0;
$scope.code = {};
$scope.code[index] = 'value';
演示
角度模块(“应用程序”,[])
.controller(“ctrl”,函数($scope){
var指数=0;
$scope.code={};
$scope.code[index]=“value”;
log($scope.code);
})
var index = 0;
$scope.code = {};
$scope.code[index] = 'value';