diff options
| author | Pete Bacon Darwin | 2013-06-11 22:35:47 +0100 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-06-11 22:35:47 +0100 |
| commit | 1fac36e2cb70be07067e73719e8f566d9c8f3177 (patch) | |
| tree | fa8e1974ce4a831935254c314a2bb2965daa3aa9 | |
| parent | 4b6c87b6e7462a5c9e8510d029adb4595dcc3e79 (diff) | |
| download | angular.js-1fac36e2cb70be07067e73719e8f566d9c8f3177.tar.bz2 | |
docs(ngRoute): clarify when gets updated
| -rw-r--r-- | src/ng/route.js | 8 | ||||
| -rw-r--r-- | src/ng/routeParams.js | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/ng/route.js b/src/ng/route.js index 587e64a7..970e9005 100644 --- a/src/ng/route.js +++ b/src/ng/route.js @@ -24,8 +24,8 @@ function $RouteProvider(){ * route definition. * * `path` can contain named groups starting with a colon (`:name`). All characters up to the - * next slash are matched and stored in `$routeParams` under the given `name` when the route - * matches. + * next slash are matched and stored in `$routeParams` under the given `name` after the route + * is resolved. * * @param {Object} route Mapping information to be assigned to `$route.current` on route * match. @@ -50,7 +50,9 @@ function $RouteProvider(){ * - `factory` - `{string|function}`: If `string` then it is an alias for a service. * Otherwise if function, then it is {@link api/AUTO.$injector#invoke injected} * and the return value is treated as the dependency. If the result is a promise, it is resolved - * before its value is injected into the controller. + * before its value is injected into the controller. Be aware that `ngRoute.$routeParams` will + * still refer to the previous route within these resolve functions. Use `$route.current.params` + * to access the new route parameters, instead. * * - `redirectTo` – {(string|function())=} – value to update * {@link ng.$location $location} path with and trigger route redirection. diff --git a/src/ng/routeParams.js b/src/ng/routeParams.js index 0202f8e5..aa8dfe5a 100644 --- a/src/ng/routeParams.js +++ b/src/ng/routeParams.js @@ -15,6 +15,10 @@ * The service guarantees that the identity of the `$routeParams` object will remain unchanged * (but its properties will likely change) even when a route change occurs. * + * Note that the `$routeParams` are only updated *after* a route change completes successfully. + * This means that you cannot rely on `$routeParams` being correct in route resolve functions. + * Instead you can use `$route.current.params` to access the new route's parameters. + * * @example * <pre> * // Given: |
