这是我的代码,如何从我的输入框中的数组更改名称? 如何在全部数组中获取所有更改的名称?先谢谢了。马可。从范围更改获取数组
app.js
var g[];
var names = ['John', 'Steve', 'Mark', 'George'];
for (var i = 1; i <= 4; i++){
g.push({myCount: i, myName: names[i]});
};
$scope.allnames = g;
$scope.Calculate = function (??????) {
console.log(' INDEX = ' + myCount ???????);
console.log(' CHANGE NAME = ' + myName ???????);
};
的index.html
<div class="row" ng-repeat="testx in allnames">
<input type="text" class="form-control" ng-model="testx.myCount"/>
<input type="text" class="form-control" ng-model="testx.myName" ng-blur="Calculate(?????)" />
</div>
首先观察,在'for'回路'i'变量应在'0'启动和停止在'<= 3 '或者你应该把'name [i]'改写成'names [i-1]'。数组基于零。 – Brett 2014-12-02 18:15:57