Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Array digest cycle issue. Push() doesn't work while .concat does #9768

Closed
bobber205 opened this issue Oct 24, 2014 · 1 comment
Closed

Array digest cycle issue. Push() doesn't work while .concat does #9768

bobber205 opened this issue Oct 24, 2014 · 1 comment

Comments

@bobber205
Copy link

So I had an array of objects I wanted to submit as a hidden form field as a json object.
It was simple enough to write a quick directive to parse the array.

My "add object" function used .push() to add to the array, which caused my directive to not fire and the json string to not be updated.

I reproduced the issue below.

http://jsfiddle.net/4eah5gqf/5/

Looks like this isn't just affecting the use ngModelController.$parsers or ngModelController.formatters. A regular ng-bind is also affected.

What I've resorted to is using concat. That seems to trigger the update I need.

$scope.my_array = $scope.my_array.concat([{key:value}]);
@Narretz
Copy link
Contributor

Narretz commented Oct 24, 2014

This is because neither ngModel nor ngBind check for objectEquality in their watch functions. For ngModel, this should be made configurable, see e.g. #7203 and ngBind should probably work like interpolation in this respect, see issue #9717

I'm gonna close this as a duplicate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants