Reputation: 1502
ng-controller="StoreController as store"
instead of
ng-controller="StoreController"
What is the difference?
Upvotes: 3
Views: 5433
Reputation: 57
Additionally, an alias is like an instance in POO. By doing this you are sure to be accessing only the StoreController scope in you code.
You can get controllers(child) which are shadowed in another controller(parent) with the same scope 'id'. Doing this {{ id }} will display the id of the parent.
Using an alias this becomes
controllers(child) as child
controller(parent) as parent
and child.id gives the id of the child and parent.id displays the id of the parent.
Hope this helps
Upvotes: 1