0

I tried to make random placeholder text on input. here is my sample code

try to Run this sample several times, then you may see error code through console.

Error: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations:

even tho placeholder text changed, bother this error message. why this code sometimes works, sometimes not works?

DK2
  • 651
  • 1
  • 7
  • 34

2 Answers2

0

From this answer:

You shouldn't change objects/models during the render or otherwise it will force a new render (and consequently a loop, which causes the 'Error: 10 $digest() iterations reached. Aborting!').

If you wan to update the model, do it on the Controller or on a Directive, never on the view. angularjs documentation recommends not to use the ng-init exactly to avoid these kind of situations:

Use ngInit directive in templates (for toy/example apps only, not recommended for real applications)

Community
  • 1
  • 1
Patrick Motard
  • 2,650
  • 2
  • 14
  • 23
0

Your Random function triggering $digest() error Here is the issue in angular js about it:-

Random function triggering $digest() error

And i searched but there is no way to work around i find.

Community
  • 1
  • 1
squiroid
  • 13,809
  • 6
  • 47
  • 67