miliu miliu - 1 year ago 101
AngularJS Question

AngularJS: How to get rid of "Error: 10 $digest() iterations reached. Aborting!"

I ran into this error in my project.

To illustrate it, I created a Plunker at

Actually, when you enter anything in search for box, there are two errors, one is

Error: 10 $digest() iterations reached. Aborting!
and the other
Uncaught Error: 10 $digest() iterations reached. Aborting!
and they seem to go together.

How to fix it?

Answer Source

You can't use two-way binding on your filter like that, because your filter is returning a new array each time and the digest loop goes on and on. You can get around this by sending in your items separately from your filter, and then using $watch to watch your searchString and created $scope.filteredItems dynamically. See here:

There may be a way to send in filter and filterType together as 1, but I don't know how to do it.

And read this answer for more details: - Angular.js pass filter to directive bi-directional ('=') attribute

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download