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

Error: 10 $digest() iterations reached when passing values to a directive #3963

Closed
gromgull opened this issue Sep 11, 2013 · 4 comments
Closed

Comments

@gromgull
Copy link

If you pass a value to a directive where bi-directional binding to the parent scope is used weird things happen.

See here: http://jsfiddle.net/7tPAr/3/

@petebacondarwin
Copy link
Contributor

So the problem is that you are defining the object in the template itself. The $parse services creates a getter for this string, which returns the given object (i.e. {"2":3}). Unfortunately, this getter function returns a new object every time it is called. This means that in the digest cycle this object changes "every" time it is checked, making the digest unstable and unable to stop.
This is easily worked around by putting the definition of the object into a variable that is referenced. See http://jsfiddle.net/tLdE6/.

@petebacondarwin
Copy link
Contributor

I guess it would be good if the parser were able to realise that this object is a constant and always return the same object. Adding to post 1.2 milestone to be looked into.

@gromgull
Copy link
Author

Thanks for the fix, that works fine!

@Narretz
Copy link
Contributor

Narretz commented Dec 18, 2013

fixed in #5385
see also http://jsfiddle.net/7tPAr/5/
@petebacondarwin

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

3 participants