This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information