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

Commit dba566a

Browse files
committed
docs($rootScope): better document infinite digest and ttl
1 parent 6d324c7 commit dba566a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

docs/content/error/rootScope/infdig.ngdoc

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
@fullName Infinite $digest Loop
44
@description
55

6-
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.
6+
This error occurs when the application's model becomes unstable and each `$digest` cycle triggers a state change and subsequent `$digest` cycle.
7+
Angular detects this situation and prevents an infinite loop from causing the browser to become unresponsive.
78

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

1011
```
1112
$scope.$watch('foo', function() {
1213
$scope.foo = $scope.foo + 1;
1314
});
14-
```
15+
```
16+
17+
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}.

src/ng/rootScope.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@
4040
* @methodOf ng.$rootScopeProvider
4141
* @description
4242
*
43-
* Sets the number of digest iterations the scope should attempt to execute before giving up and
44-
* assuming that the model is unstable.
43+
* Sets the number of `$digest` iterations the scope should attempt to execute before giving up and assuming that the model is unstable.
4544
*
4645
* The current default is 10 iterations.
4746
*
47+
* In complex applications it's possible that the dependencies between `$watch`s will result in several digest iterations.
48+
* 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.
49+
*
50+
* Increasing the TTL could have performance implications, so you should not change it without proper justification.
51+
*
4852
* @param {number} limit The number of digest iterations.
4953
*/
5054

0 commit comments

Comments
 (0)