File tree 1 file changed +14
-6
lines changed 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
@@ -632,12 +636,16 @@ function $RootScopeProvider(){
632
636
expect(scope.counter).toEqual(0);
633
637
634
638
scope.$digest();
635
- // no variable change
636
- expect(scope.counter).toEqual(0 );
639
+ // the listener is always called during the first $digest loop after it was registered
640
+ expect(scope.counter).toEqual(1 );
637
641
638
- scope.name = 'adam';
639
642
scope.$digest();
643
+ // but now it will not be called unless the value changes
640
644
expect(scope.counter).toEqual(1);
645
+
646
+ scope.name = 'adam';
647
+ scope.$digest();
648
+ expect(scope.counter).toEqual(2);
641
649
* ```
642
650
*
643
651
*/
You can’t perform that action at this time.
0 commit comments