0
why angular controller runs twice?
controller creared with constructor, and then added a simple log funtion with prototype . logged string is showed twice. why ?
1 Answer
0
Every time the Angular Engine goes through the DOM, it checks it at least twice: once to make changes, and another to check for changes to the $scope variables. If you had functions or other events within the document, it could potentially keep running.
The engine will check the DOM again, every time you call $timeout or $apply or every time the user interacts (with a button, or checkbox etc) which would trigger this event at least two more times each.
The amazing aspect of this is that the average computer belonging to average Joe Shmo is fast enough to keep up with all of this checking!! :)