Merge pull request #1846 from yurivish/patch-1
Improve the documentation of routing parameters
This commit is contained in:
commit
1370551104
1 changed files with 3 additions and 1 deletions
|
|
@ -124,7 +124,7 @@ Argument | Type | Required | Description
|
|||
|
||||
##### m.route.param
|
||||
|
||||
Retrieves a route parameter. A route parameter is a key-value pair. Route parameters may come from a few different places:
|
||||
Retrieves a route parameter from the last fully resolved route. A route parameter is a key-value pair. Route parameters may come from a few different places:
|
||||
|
||||
- route interpolations (e.g. if a route is `/users/:id`, and it resolves to `/users/1`, the route parameter has a key `id` and value `"1"`)
|
||||
- router querystrings (e.g. if the path is `/users?page=1`, the route parameter has a key `page` and value `"1"`)
|
||||
|
|
@ -137,6 +137,8 @@ Argument | Type | Required | Description
|
|||
`key` | `String` | No | A route parameter name (e.g. `id` in route `/users/:id`, or `page` in path `/users/1?page=3`, or a key in `history.state`)
|
||||
**returns** | `String|Object` | | Returns a value for the specified key. If a key is not specified, it returns an object that contains all the interpolation keys
|
||||
|
||||
Note that in the `onmatch` function of a RouterResolver, the new route hasn't yet been fully resolved, and `m.route.params()` will return the parameters of the previous route, if any. `onmatch` receives the parameters of the new route as an argument.
|
||||
|
||||
#### RouteResolver
|
||||
|
||||
A RouterResolver is an object that contains an `onmatch` method and/or a `render` method. Both methods are optional, but at least one must be present. A RouteResolver is not a component, and therefore it does NOT have lifecycle methods. As a rule of thumb, RouteResolvers should be in the same file as the `m.route` call, whereas component definitions should be in their own modules.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue