0

I use a same controller twice on my page, with same data, but i display it not in the same way (not same parts of the array).

I can see with ng-inspector that the scope is correctly updated when i perform some change, and it's duplicate. But in the view, it's doesn't change ! A simple param to false by default and passed at true with a simple timeout, in the view, it's always to false.

If i display only one time the ng-controller, the view it's updated.

How to correct that ?

zelocalhost
  • 1,175
  • 3
  • 20
  • 39

1 Answers1

0

Ok, so you didn't actually give much in the way of code, but this sounds like you're falling victim to one of the classic scope blunders. The first thing to try is to use properties of objects, not primitives on the scope.

This means instead of using this code ---

$scope.myBool = false;
{{myBool}}

use this code ---

$scope.myBool = { value: false };
{{myBool.value}}

The reason being is that Angular likes to do funny stuff like use prototype for new scopes. This means you'll get the prototype of the parent scope, and then when you instantiate your scope, you can override the parents prototype with your new value, without changing the parents value. You get past this by using an object on the scope instead.

The second option that might be occurring is you're doing something that isn't causing an angular digest cycle to happen. You might need to manually kick one off.

Without seeing any code, there's no telling, though.

Paul
  • 276
  • 1
  • 8