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

Commit

Permalink
docs($rootScope): better document infinite digest and ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed Oct 15, 2013
1 parent 6d324c7 commit dba566a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions docs/content/error/rootScope/infdig.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
@fullName Infinite $digest Loop
@description

This error occurs when the application's model becomes unstable and each `$digest` cycle triggers a state change and subsequent `$digest` cycle. Angular detects this situation and prevents an infinite loop from causing the browser to become unresponsive.
This error occurs when the application's model becomes unstable and each `$digest` cycle triggers a state change and subsequent `$digest` cycle.
Angular detects this situation and prevents an infinite loop from causing the browser to become unresponsive.

For example, the situation can occur by setting up a watch on a path and subsequently updating the same path when the value changes.

```
$scope.$watch('foo', function() {
$scope.foo = $scope.foo + 1;
});
```
```

The maximum number of allowed iterations of the `$digest` cycle is controlled via TTL setting which can be configured via {@link api/ng.$rootScopeProvider $rootScopeProvider}.
8 changes: 6 additions & 2 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@
* @methodOf ng.$rootScopeProvider
* @description
*
* Sets the number of digest iterations the scope should attempt to execute before giving up and
* assuming that the model is unstable.
* Sets the number of `$digest` iterations the scope should attempt to execute before giving up and assuming that the model is unstable.
*
* The current default is 10 iterations.
*
* In complex applications it's possible that the dependencies between `$watch`s will result in several digest iterations.
* However if an application needs more than the default 10 digest iterations for its model to stabilize then you should investigate what is causing the model to continuously change during the digest.
*
* Increasing the TTL could have performance implications, so you should not change it without proper justification.
*
* @param {number} limit The number of digest iterations.
*/

Expand Down

0 comments on commit dba566a

Please sign in to comment.