Skip to main content
added 306 characters in body
Source Link
Michael Kang
  • 53k
  • 16
  • 108
  • 138

That is the way that the $digest cycle works. When a $digest is triggered, angular will loop through all the $watch expressions and determine if they have changed. This happens for all $watch expressions on all scopes - a process called dirty-checking.

The reason that myFunction() is being called is because you have an implicit $watch on it as a result of the binding expression:

{{myFunction()}}

This is normal and nothing to be concerned about.

The reason that the $digest cycle is being triggered periodically is because of your $timeout function. By default, it will invoke your timeout function within an $apply block which, in turn, triggers the $digest. You can disable this behavior by passing false as the third argument to $timeout.

I would like to suggest that you use $interval$interval instead of $timeout$timeout. It is better suited for this.

That is the way that the $digest cycle works. When a $digest is triggered, angular will loop through all the $watch expressions and determine if they have changed. This happens for all $watch expressions on all scopes - a process called dirty-checking.

The reason that myFunction() is being called is because you have an implicit $watch on it as a result of the binding expression:

{{myFunction()}}

This is normal and nothing to be concerned about.

I would like to suggest that you use $interval instead of $timeout. It is better suited for this.

That is the way that the $digest cycle works. When a $digest is triggered, angular will loop through all the $watch expressions and determine if they have changed. This happens for all $watch expressions on all scopes - a process called dirty-checking.

The reason that myFunction() is being called is because you have an implicit $watch on it as a result of the binding expression:

{{myFunction()}}

This is normal and nothing to be concerned about.

The reason that the $digest cycle is being triggered periodically is because of your $timeout function. By default, it will invoke your timeout function within an $apply block which, in turn, triggers the $digest. You can disable this behavior by passing false as the third argument to $timeout.

I would like to suggest that you use $interval instead of $timeout. It is better suited for this.

Source Link
Michael Kang
  • 53k
  • 16
  • 108
  • 138

That is the way that the $digest cycle works. When a $digest is triggered, angular will loop through all the $watch expressions and determine if they have changed. This happens for all $watch expressions on all scopes - a process called dirty-checking.

The reason that myFunction() is being called is because you have an implicit $watch on it as a result of the binding expression:

{{myFunction()}}

This is normal and nothing to be concerned about.

I would like to suggest that you use $interval instead of $timeout. It is better suited for this.