feat(ngView): reference resolved locals in scope
All the resolves for a route are now attached to the route's local scope,
as the property whose name is given by the `resolveAs` property on the
route definition.
If `resolveAs` is not specified it defaults to `$resolve`.
This will make it easier to use `ngRoute`, by being able to reference all
the resolve values for the route, directly on the scope, rather than having
to implement a controller just to copy the resolves across manually.
For example, rather than
```js
$routeProvider.when('/', {
resolve: {
item1: ($http) => $http.get(...),
item2: ($http) => $http.get(...)
},
template: '<my-app item1="vm.item1" item2="vm.item2">'</my-app>`,
controllerAs: 'vm',
controller: ['item1', 'item2', function(item1, item2) {
this.item1 = item1;
this.item2 = item2;
}]
});
```
one can now do
```js
$routeProvider.when('/', {
resolve: {
item1: ($http) => $http.get(...),
item2: ($http) => $http.get(...)
},
template: '<my-app item1="$resolve.item1" item2="$resolve.item2">'</my-app>`
});
```
BREAKING CHANGE:
A new property is being attached to the scope of the route. The default name
for this property is `$resolve`. If your scope already contains a property
with this name then it will be hidden or overwritten.
In this case, you should choose a custom name for this property, that will
not collide with other properties on the scope, by specifying the `resolveAs`
property on the route.
Closes #13400 S
Shahar Talmi committed
983b0598121a8c5a3a51a30120e114d7e3085d4d
Parent: 25e8c59
Committed by Peter Bacon Darwin <pete@bacondarwin.com>
on 12/4/2015, 12:22:23 PM