Reputation: 1199
In Durandal, I have map router
router.map([
{ route: 'tickets/:id', moduleId: 'tickets/thread', nav: true }
]).buildNavigationModel();
I have link in address bar
http://localhost:8083/#tickets/ticket001
In my viewModel
, how can i get the value of id
?
Upvotes: 3
Views: 3145
Reputation: 2198
You can also get them via the activate function on your view model. All parameters in the router will be passed as arguments to your activate function. see the "Route Parameters and Query Strings" section in the router docs:
http://durandaljs.com/documentation/Using-The-Router.html
Upvotes: 3
Reputation: 1199
I found the anwers, use route plugin:
define(['knockout', 'plugins/router'],
function (ko, router) {
return {
param = router.activeInstruction().params[0]
};
});
Upvotes: 2