Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit fbbc29b

Browse files
committed
docs($routeProvider): document resolveAs and assiging resolve map on scope
Related to #13400.
1 parent e4e5677 commit fbbc29b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/ngRoute/route.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,14 @@ function $RouteProvider() {
100100
* If all the promises are resolved successfully, the values of the resolved promises are
101101
* injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is
102102
* fired. If any of the promises are rejected the
103-
* {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. The map object
104-
* is:
103+
* {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired.
104+
* For easier access to the resolved dependencies from the template, the `resolve` map will
105+
* be available on the scope of the route, under `$resolve` (by default) or a custom name
106+
* specified by the `resolveAs` property (see below).
107+
* **Note:** If your scope already contains a property with this name, it will be hidden or
108+
* overwritten. Make sure, you specify an appropriate name for this property, that
109+
* does not collide with other properties on the scope.
110+
* The map object is:
105111
*
106112
* - `key` – `{string}`: a name of a dependency to be injected into the controller.
107113
* - `factory` - `{string|function}`: If `string` then it is an alias for a service.
@@ -111,6 +117,9 @@ function $RouteProvider() {
111117
* `ngRoute.$routeParams` will still refer to the previous route within these resolve
112118
* functions. Use `$route.current.params` to access the new route parameters, instead.
113119
*
120+
* - `resolveAs` - {string=} - The name under which the `resolve` map will be available on the
121+
* scope of the route. If omitted, defaults to `$resolve`.
122+
*
114123
* - `redirectTo` – {(string|function())=} – value to update
115124
* {@link ng.$location $location} path with and trigger route redirection.
116125
*
@@ -260,14 +269,17 @@ function $RouteProvider() {
260269
* @property {Object} current Reference to the current route definition.
261270
* The route definition contains:
262271
*
263-
* - `controller`: The controller constructor as define in route definition.
272+
* - `controller`: The controller constructor as defined in the route definition.
264273
* - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for
265274
* controller instantiation. The `locals` contain
266275
* the resolved values of the `resolve` map. Additionally the `locals` also contain:
267276
*
268277
* - `$scope` - The current route scope.
269278
* - `$template` - The current route template HTML.
270279
*
280+
* The `locals` will also be assigned to the controller's `$resolve` property. You can
281+
* override the property name using `resolveAs` in the route definition.
282+
*
271283
* @property {Object} routes Object with all route configuration Objects as its properties.
272284
*
273285
* @description

0 commit comments

Comments
 (0)