I have a problem with the following code: Plunkr.
When I click the button, the ng-click
changes the variable var1
in scope. But apparently this variable is not updated in view, which I have created with UI Router. It looks like the scope have been copied inside the same controller.
The problem disappears in two situations: when I use {{$parent.var1}}
instead of {{var1}}
from inside my view, OR when I remove controller: 'MainCtrl'
declaration from my state.
Can anyone clarify what's going on and how to avoid such problems? I like the solution with removing the controller declaration but how Angular UI Router will figure out which controller to use?