This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -261,13 +261,17 @@ function $RootScopeProvider(){
261
261
expect(scope.counter).toEqual(0);
262
262
263
263
scope.$digest();
264
- // no variable change
265
- expect(scope.counter).toEqual(0 );
264
+ // the listener is always called during the first $digest loop after it was registered
265
+ expect(scope.counter).toEqual(1 );
266
266
267
- scope.name = 'adam';
268
267
scope.$digest();
268
+ // but now it will not be called unless the value changes
269
269
expect(scope.counter).toEqual(1);
270
270
271
+ scope.name = 'adam';
272
+ scope.$digest();
273
+ expect(scope.counter).toEqual(2);
274
+
271
275
272
276
273
277
// Using a listener function
@@ -574,12 +578,16 @@ function $RootScopeProvider(){
574
578
expect(scope.counter).toEqual(0);
575
579
576
580
scope.$digest();
577
- // no variable change
578
- expect(scope.counter).toEqual(0 );
581
+ // the listener is always called during the first $digest loop after it was registered
582
+ expect(scope.counter).toEqual(1 );
579
583
580
- scope.name = 'adam';
581
584
scope.$digest();
585
+ // but now it will not be called unless the value changes
582
586
expect(scope.counter).toEqual(1);
587
+
588
+ scope.name = 'adam';
589
+ scope.$digest();
590
+ expect(scope.counter).toEqual(2);
583
591
* ```
584
592
*
585
593
*/
You can’t perform that action at this time.
0 commit comments