single page application - Durandal Routing - routing to a resource with a particular id? -


i'm trying configure routing navigating #/my displays contents #/folder/62 (or id stored in variable) - , navigating #/public displays contents #/folder/1 (same concept).

additionally, i'd application navigate 1 of these routes upon loading, depending on whether or not user authenticated. authentication stuff done, once above routes have been configured, i'd activate on 1 of them.

here's have:

        activate: function () {         router.useconvention();         router.handleinvalidroute = function (route, params) {             //debugger;             logger.logerror("invalid route", route, null, true);         };          router.map([                             { url: 'home', moduleid: 'viewmodels/home', name: 'home', visible: false },                            { url: 'my', moduleid: 'viewmodels/folder', name: 'my content', visible: false }, // should display contents of /folder/2             { url: 'public', moduleid: 'viewmodels/folder', name: 'public content', visible: false }, // should display contents of /folder/3             { url: 'set/:id', moduleid: 'viewmodels/set', name: 'set', visible: false },             { url: 'folder/:id', moduleid: 'viewmodels/folder', name: 'folder', visible: false }         ]);          if (auth.isauthenticated)             return router.activate('my'); // should show details page of particular folder         else {             return router.activate('public'); // should show details page of particular folder         }     } 

app.setroot described in https://groups.google.com/forum/#!searchin/durandaljs/app.setroot/durandaljs/t1hrlfoh1om/rtcekmy0bdaj used show different views authenticated/non-authenticated users.

if authenticated users should allowed see content of "folder/specialid" in example might consider not expose these via router. use standard compose functionality in #my load specialid view/view model instead.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -