Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You probably need to setup a second route with the same <code>moduleId</code>. Here's a live example for child routes that uses this <a href="http://dfiddle.github.io/dFiddle-2.0/#hello" rel="nofollow">http://dfiddle.github.io/dFiddle-2.0/#hello</a> and <a href="http://dfiddle.github.io/dFiddle-2.0" rel="nofollow">http://dfiddle.github.io/dFiddle-2.0</a> </p> <pre class="lang-js prettyprint-override"><code>define(['plugins/router', 'durandal/system', 'global', 'knockout'], function( router, system, global, ko ) { var childRouter = router.createChildRouter() .makeRelative({ moduleId: 'hello', route: 'hello' }).map([ {route: '', moduleId: 'default/index', title: 'Hello World', type: 'intro'}, {route: 'default', moduleId: 'default/index', title: 'Hello World', type: 'intro', nav: true}, {route: 'dFiddle', moduleId: 'dFiddle/index', title: 'Hello World', type: 'fiddle', nav: true} ]).buildNavigationModel(); // .on is mixed in an not meant to be chainable childRouter.on('router:navigation:complete').then(global.createSampleLink); return { global: global, router: childRouter, getItemsByCategoryId: function( categoryId ) { return ko.utils.arrayFilter(childRouter.navigationModel(), function( route ) { return route.type === categoryId; }); }, binding: function() { system.log('Lifecycle : binding : hello/index'); return { cacheViews: false }; //cancels view caching for this module, allowing the triggering of the detached callback } }; }); </code></pre> <p>This specific setup that has child routes on all top routes use <code>router.guardRoute</code> in <code>shell.js</code> to handle the empty root case. There's an open ticket <a href="https://github.com/BlueSpire/Durandal/issues/240" rel="nofollow">https://github.com/BlueSpire/Durandal/issues/240</a> that discusses better handling of these kind of edge cases.</p> <pre class="lang-js prettyprint-override"><code>define(['plugins/router'], function (router) { // Redirecting from / to first route router.guardRoute = function(routeInfo, params, instance){ if (params.fragment === ''){ return routeInfo.router.routes[0].hash; } return true; }; return { router: router, activate: function () { router.map([ { route: '', moduleId: 'hello/index', title: 'Hello World' }, { route: 'hello*details', hash: '#hello', moduleId: 'hello/index', title: 'Hello World', nav: true }, ... ]).buildNavigationModel(); return router.activate(); } }; }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload