docs($rootScope): fix incorrect docs and make them clearer

During the first $digest loop after registering a $watch
the listener always run, so the example was incorrect

Closes #7598
This commit is contained in:
Pavel Pomerantsev
2014-05-25 11:53:28 +04:00
committed by rodyhaddad
parent 0dbec22bc7
commit 7a9d24551f

View File

@@ -261,12 +261,16 @@ function $RootScopeProvider(){
expect(scope.counter).toEqual(0);
scope.$digest();
// no variable change
expect(scope.counter).toEqual(0);
// the listener is always called during the first $digest loop after it was registered
expect(scope.counter).toEqual(1);
scope.$digest();
// but now it will not be called unless the value changes
expect(scope.counter).toEqual(1);
scope.name = 'adam';
scope.$digest();
expect(scope.counter).toEqual(1);
expect(scope.counter).toEqual(2);
@@ -632,12 +636,16 @@ function $RootScopeProvider(){
expect(scope.counter).toEqual(0);
scope.$digest();
// no variable change
expect(scope.counter).toEqual(0);
// the listener is always called during the first $digest loop after it was registered
expect(scope.counter).toEqual(1);
scope.$digest();
// but now it will not be called unless the value changes
expect(scope.counter).toEqual(1);
scope.name = 'adam';
scope.$digest();
expect(scope.counter).toEqual(1);
expect(scope.counter).toEqual(2);
* ```
*
*/