0

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();
SB2055
  • 12,272
  • 32
  • 97
  • 202
  • Can you clarify as to the point at which you need to conditionally select the route? Do you mean to say that, when the user enters the application, the shell needs to conditionally select the initial route based on some criteria? Could you show us the logic of your conditional? Thanks. –  Feb 06 '15 at 06:21

2 Answers2

0

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.

SB2055
  • 12,272
  • 32
  • 97
  • 202
0

You can specify which route to use on activate with the startRoute argument, as follows:

return router.activate({
    startRoute: "myStartRoute"
});
Matthew Sharpe
  • 3,667
  • 2
  • 25
  • 24