0
我試圖更新classRollNum價值,但在控制檯上其壁上的反射打印時。我在這裏做什麼錯>如何更新範圍值
function classRollNumCtrl($scope, studentList, Restangular) {
var vm = this;
vm.studentList = studentList.plain();
vm.updateRollNum = function() {
for (var x in vm.studentList) {
console.log("x --> " + x)
vm.studentList.classRollNum= x+1; // UPDATEING VALUE
}
console.log("vm.studentList --> " + JSON.stringify(vm.studentList));
}
}
}());
我的vm.studentList看起來像這樣。
vm.studentList = [
{"studentName":"Abhinav Chandel","classRollNum":null},
{"studentName":"Achin Agarwal","classRollNum":null},
{"studentName":"Amartya Khan","classRollNum":null}
]
困惑於自己在做什麼。爲什麼不在控制器中聲明'vm.studentList = [...'? –
@ LJ.Wizard:上面的更正。 vm.studentList是我對studentList的決心。我很驚訝爲什麼vm.studentList.classNumRoll = x + 1;是不是更新值 – fresher
因爲'classNumRoll'!='classRollNum' – dex