javascript - Angularjs - unexpected order of execution -


i have strange problem causes problem in ie (any version) not chrome.

i have array called "items" within object called "doc" - users can edit items deletes item adds content text box users can add again after making changes.

the code edit function is:

$scope.edititem = function(index) {     console.log($scope.doc); //debugging     item = $scope.doc.items[index];     $scope.content = item.data     $scope.doc.items.splice(index,1); }; 

starting out 3 items, during debugging i've noticed console.log($scope.doc) (line 2) outputs doc 2 items in it. before array has been spliced. expect there 3 items.

i've checked index passed correctly view isn't problem area.

why happening?

it can console.log prints object not immediately(possibly saves reference , prints bit later).

try replace console.log($scope.doc); console.log($scope.doc.length); or console.log(json.stringify($scope.doc));


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -