Improve the documentation of routing parameters
I was stuck on this for a while earlier today: it turns out that `m.route.param` will not return the right results in the `onmatch` function on a `RouterResolver`, though it will inside of a `render` function on the same. This behavior is documented in the `onmatch` section but not the `m.route.param` section, which is where I was looking when I ran up against this earlier. From an API design perspective it would make sense to me for `m.route.param` to return valid results inside `onmatch`, but I don't know enough about Mithril's internals to know how complex it would be to implement.
This commit is contained in:
parent
10b8507c1b
commit
a560bca85d
1 changed files with 1 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. A route parameter is a key-value pair. Note that in the `onmatch` function of a RouterResolver, route parameters are unavailable from `m.route.param` and are passed as an argument instead due to internal timing of the route resolution mechanism. 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"`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue