Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

"Model did not stabilize" error for not changing variable #678

Closed
lohnicky opened this issue Mar 5, 2014 · 12 comments
Closed

"Model did not stabilize" error for not changing variable #678

lohnicky opened this issue Mar 5, 2014 · 12 comments

Comments

@lohnicky
Copy link

lohnicky commented Mar 5, 2014

Create ng-component with 2 variables:

    @NgComponent(
      selector: 'mycomponent',
      templateUrl: 'mycomponent.html',
      publishAs: 'ctrl',
      applyAuthorStyles: true
    )
    class MyComponent {
      List<bool> boolList = [false, true];
      String url = "http://helloworld.com";
    }

and create template for the component:

    <div id="my-component">
      <div ng-repeat="val in ctrl.boolList">
        <div ng-if="!val">
          <div ng-if="!val">
            <a href="{{ctrl.url}}">Hello World</a>
          </div>
        </div>
      </div>
    </div>

Running the code will result into following error:

Model did not stabilize in 5 digests. Last 3 iterations:
!(val): true <= null
[[href={{ctrl.url}}]](ctrl.url): [http://helloworld.com] <= null
STACKTRACE:
#0      RootScope.digest (package:angular/core/scope.dart:475:11)
#1      RootScope.digest (package:angular/core/scope.dart:480:7)
#2      RootScope.digest (package:angular/core/scope.dart:480:7)
#3      apply (package:angular/core/scope.dart:251:19)
#4      _rootRun (dart:async/zone.dart:688)
#5      _rootRun (dart:async/zone.dart:689)
#6      _rootRun (dart:async/zone.dart:689)
#7      _ZoneDelegate.run (dart:async/zone.dart:417)
#8      NgZone._finishTurn (package:angular/core/zone.dart:95:21)
#9      NgZone._onRunBase (package:angular/core/zone.dart:60:43)
#10     _onRunUnary (package:angular/core/zone.dart:69:15)
#11     _ZoneDelegate.runUnary (dart:async/zone.dart:426)
#12     _CustomizedZone.runUnary (dart:async/zone.dart:631)
#13     _BaseZone.runUnaryGuarded (dart:async/zone.dart:546)
#14     _BaseZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:572)

Operating system: Ubuntu 12.04 LTS
Browser: Chromium (Dartium) Version 31.0.1650.48 (240209)

It looks like that the problem is in specifying the ctrl.url in the attribute of an html element. On the other this works:

        <a href="">{{ctrl.url}}</a>

Also the ng-if parts doesn't need to be the same variable, but the order of true/false values should be the same.

@zoechi
Copy link
Contributor

zoechi commented Mar 6, 2014

Take a look at this SO Q/A http://stackoverflow.com/questions/21763136

@lohnicky
Copy link
Author

lohnicky commented Mar 6, 2014

How is this related? It's different error and I don't have duplicates in my example.

@zoechi
Copy link
Contributor

zoechi commented Mar 6, 2014

I thought I read somewhere that items in collections repeated over should not be primitive values. I thought it might be worth a try. Have you tried it?

@lohnicky
Copy link
Author

lohnicky commented Mar 6, 2014

Yes, this occured for me at first with instances of a complex class with different attributes in ng-if. This is just minimal example that I was able to to extract. Also when you remove one of the if statement it works.

@pavelgj
Copy link
Contributor

pavelgj commented Mar 6, 2014

Here's the simplest repro:

    <div ng-if="1 == 1">
      <div ng-if="1 == 1">
        <div ng-if="1 == 1">
          <div ng-if="1 == 1">
            Oops....
          </div>
        </div>
      </div>
    </div>
Model did not stabilize in 5 digests. Last 3 iterations:
==(1, 1): true <= null
==(1, 1): true <= null

STACKTRACE:
#0      RootScope.digest (package:angular/core/scope.dart:477:11)
#1      RootScope.digest (package:angular/core/scope.dart:482:7)
#2      RootScope.digest (package:angular/core/scope.dart:482:7)
#3      apply (package:angular/core/scope.dart:252:19)
#4      _rootRun (dart:async/zone.dart:710)
#5      _rootRun (dart:async/zone.dart:711)
#6      _rootRun (dart:async/zone.dart:711)
#7      _ZoneDelegate.run (dart:async/zone.dart:440)
#8      NgZone._finishTurn (package:angular/core/zone.dart:95:21)
#9      NgZone._onRunBase (package:angular/core/zone.dart:60:43)
#10     _onRun (package:angular/core/zone.dart:65:15)
#11     _ZoneDelegate.run (dart:async/zone.dart:440)
#12     _CustomizedZone.run (dart:async/zone.dart:650)
#13     NgZone.run (package:angular/core/zone.dart:147:35)
#14     ngBootstrap (package:angular/bootstrap.dart:91:18)
#15     main (repro.dart:13:14)

@chalin
Copy link
Contributor

chalin commented Mar 6, 2014

/sub

@pavelgj
Copy link
Contributor

pavelgj commented Mar 6, 2014

Similarly:

    <div ng-repeat="a in [1]">
      <div ng-repeat="b in [1]">
        <div ng-repeat="c in [1]">
          <div ng-repeat="d in [1]">
            Oops...
          </div>
        </div>
      </div>
    </div>

@pavelgj
Copy link
Contributor

pavelgj commented Mar 6, 2014

Test case:

    it('should allow multiple nested watches', inject((RootScope scope) {
      scope.watch('1', (_, __) {
        scope.watch('1', (_, __) {
          scope.watch('1', (_, __) {
            scope.watch('1', (_, __) {
              //...
            });
          });
        });
      });
      expect(scope.apply).not.toThrow();
    }));

@mhevery mhevery self-assigned this Mar 6, 2014
@mhevery
Copy link
Contributor

mhevery commented Mar 6, 2014

OK, I will take another look at this.

@mhevery
Copy link
Contributor

mhevery commented Mar 7, 2014

The issue is this: cd4e2e3

@mhevery mhevery closed this as completed in d6bc9ab Mar 7, 2014
@vicb
Copy link
Contributor

vicb commented Mar 7, 2014

side note: you can /sub with the top-right notifications menu

@chalin
Copy link
Contributor

chalin commented Mar 7, 2014

(Thanks for the side-note Vic)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

6 participants