Thursday, 15 March 2012

AngularJS: nested array and view update -



AngularJS: nested array and view update -

i'm having problems updating view after array within array updated in $scope.

first check if array fellow member exists:

$scope.myarray = []; if(typeof $scope.myarray[someindex] == 'undefined') { $scope.myarray[someindex] = { name: somename, data: [] }; }

then force $scope.myarray[someindex].data:

$scope.myarray[someindex].data.push(datacontent);

at point view not update.

of course of study if straight force $scope.myarray does. suggestions?

edit: fiddle here

it simpler looked.

based on response here setting associative array allows set string keys. if declare array =[] cannot set strings keys.

so changed declaration $scope.myarray=[] $scope.myarray={} , voilĂ , works.

angularjs angularjs-scope

No comments:

Post a Comment