You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
In 1.2.0-rc3, if you had both ng-if and ng-controller on the same element, when ng-if condition changed, you would get a new controller. This occurred even if you changed from true -> true. I'm not sure what the expected behavior is here, but in 1.2.0, the controller is only ever instantiated once.
Is this the desired behavior? Is this documented anywhere?
Since this is what I desired in my case, I was able to fix by using both ng-repeat and ng-if:
<divng-if="selectedItem" ng-repeat="selectedItem in [selectedItem]" ng-controller="ProductController></div>
In this example, ng-repeat is what is instantiating the new controller for each new element.
ng-controller has a lower priority than ng-if so it will be reinstantiated each time so you would expect a new controller each time ng-if value changed. I believe there is another PR somewhere the picks up on the fact that if that value goes from true -> true it still reinstantiates.
In 1.2.0-rc3, if you had both ng-if and ng-controller on the same element, when ng-if condition changed, you would get a new controller. This occurred even if you changed from true -> true. I'm not sure what the expected behavior is here, but in 1.2.0, the controller is only ever instantiated once.
Is this the desired behavior? Is this documented anywhere?
Since this is what I desired in my case, I was able to fix by using both ng-repeat and ng-if:
In this example, ng-repeat is what is instantiating the new controller for each new element.
Plunker showing the difference:
http://plnkr.co/edit/uTJSrY0SQI1AdaK2rjJI?p=preview
The text was updated successfully, but these errors were encountered: