Reputation: 487
I have a $scope.test.name
in both 'test1' controller
and 'test2' controller
.
The backdrop:
'test2' controller
is a pop-out page open above 'test1' controller
pagethe issue:
'test2' controller
, if i change value of $scope.test.name
, it will also change value of $scope.test.name
of controller 1, since both 'test1' controller
and 'test1' controller
are open concurentlyIs there a way to isolate or cut off relation of $scope.test.name
from both controller beside giving a different name?
Upvotes: 0
Views: 353
Reputation: 3245
You can use the controller as syntax:
<div ng-controller="Test1Ctrl as test1">
{{ test1.test.name }}
<div ng-controller="Test2Ctrl as test2">
{{ test2.test.name }}
</div>
</div>
Upvotes: 2
Reputation: 1718
that's because of parent child relationship and test2 comes inside test1 so it will reflect the changes but vice-versa it will not work i will recommend you using directive with isolated scope.
you can refer here https://thinkster.io/egghead/understanding-isolate-scope
Upvotes: 1