mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-05-31 02:41:32 +08:00
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:
committed by
rodyhaddad
parent
0dbec22bc7
commit
7a9d24551f
@@ -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);
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user