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

Commit 472660c

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

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/ngRoute/route.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,17 @@ 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). This can be particularly useful, when
107+
* working with {@link angular.Module#component components} as route templates.<br />
108+
* <div class="alert alert-warning">
109+
* **Note:** If your scope already contains a property with this name, it will be hidden
110+
* or overwritten. Make sure, you specify an appropriate name for this property, that
111+
* does not collide with other properties on the scope.
112+
* </div>
113+
* The map object is:
105114
*
106115
* - `key` – `{string}`: a name of a dependency to be injected into the controller.
107116
* - `factory` - `{string|function}`: If `string` then it is an alias for a service.
@@ -111,7 +120,10 @@ function $RouteProvider() {
111120
* `ngRoute.$routeParams` will still refer to the previous route within these resolve
112121
* functions. Use `$route.current.params` to access the new route parameters, instead.
113122
*
114-
* - `redirectTo` – {(string|function())=} – value to update
123+
* - `resolveAs` - `{string=}` - The name under which the `resolve` map will be available on
124+
* the scope of the route. If omitted, defaults to `$resolve`.
125+
*
126+
* - `redirectTo` – `{(string|function())=}` – value to update
115127
* {@link ng.$location $location} path with and trigger route redirection.
116128
*
117129
* If `redirectTo` is a function, it will be called with the following parameters:
@@ -124,13 +136,13 @@ function $RouteProvider() {
124136
* The custom `redirectTo` function is expected to return a string which will be used
125137
* to update `$location.path()` and `$location.search()`.
126138
*
127-
* - `[reloadOnSearch=true]` - {boolean=} - reload route when only `$location.search()`
139+
* - `[reloadOnSearch=true]` - `{boolean=}` - reload route when only `$location.search()`
128140
* or `$location.hash()` changes.
129141
*
130142
* If the option is set to `false` and url in the browser changes, then
131143
* `$routeUpdate` event is broadcasted on the root scope.
132144
*
133-
* - `[caseInsensitiveMatch=false]` - {boolean=} - match routes without being case sensitive
145+
* - `[caseInsensitiveMatch=false]` - `{boolean=}` - match routes without being case sensitive
134146
*
135147
* If the option is set to `true`, then the particular route can be matched without being
136148
* case sensitive
@@ -260,14 +272,18 @@ function $RouteProvider() {
260272
* @property {Object} current Reference to the current route definition.
261273
* The route definition contains:
262274
*
263-
* - `controller`: The controller constructor as define in route definition.
275+
* - `controller`: The controller constructor as defined in the route definition.
264276
* - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for
265277
* controller instantiation. The `locals` contain
266278
* the resolved values of the `resolve` map. Additionally the `locals` also contain:
267279
*
268280
* - `$scope` - The current route scope.
269281
* - `$template` - The current route template HTML.
270282
*
283+
* The `locals` will be assigned to the route scope's `$resolve` property. You can override
284+
* the property name, using `resolveAs` in the route definition. See
285+
* {@link ngRoute.$routeProvider $routeProvider} for more info.
286+
*
271287
* @property {Object} routes Object with all route configuration Objects as its properties.
272288
*
273289
* @description

0 commit comments

Comments
 (0)