param
Creates a url fragment that represents provided state.
route.param( data )
Parameterizes the raw JS object representation provided in data. Any remaining data is added at the end of the URL as & separated key/value parameters.
import {route} from "can";
route.register( "{type}/{id}" );
const video = route.param( { type: "video", id: 5 } );
console.log( video ); // -> "video/5"
const notNewVideo = route.param( { type: "video", id: 5, isNew: false } );
console.log( notNewVideo ); // -> "video/5&isNew=false"
Parameters
- object
{data}
:The data to populate the route with.
- currentRouteName
{String}
:The current route name. If provided, this can be used to "stick" the url to a previous route. By "stick", we mean that if there are multiple registered routes that match the
object
, thecurrentRouteName
will be used.
Returns
{String}
:
The route, with the data populated in it.