durandaldurandal-2.0

Durandal activating to specific route not working


I have the following:

<div class="page-host" data-bind="router: { transition:'entrance' }"></div>

And with the standard router configuration, I call:

return router.activate('browse');

however, I get "hello" routed every time. I need to conditionally select which route to navigate to from within shell - how can this be done?

My routeConfig:

router.map([
                { route: ['', 'hello'], title: 'hello', moduleId: 'hello/hello', nav: true, allowedUsers: ['authenticated', 'unauthenticated'] },

                { route: 'browse', moduleId: 'browse/browse', nav: true, allowedUsers: ['authenticated'] },

                { route: 'resetpassword/:id', moduleId: 'forgot/reset', nav: false, allowedUsers: ['unauthenticated'] }

            ]).buildNavigationModel();

Solution

  • I ended up extracting the routes array and manipulating it to set the default route before calling router.map - though I'll leave this open in case there's a better way.