What i have
An attempt to understand what is happening and how to control it. I have a βpublicβ view for users who have not yet authenticated, and a βhomeβ view for authenticated users. Here is my route configuration:
app.start().then(function() { //Replace 'viewmodels' in the moduleId with 'views' to locate the view. //Look for partial views in a 'views' folder in the root. viewLocator.useConvention(); //configure routing router.useConvention(); router.mapRoute('home', 'viewmodels/home', 'Test App', true); router.mapRoute('public', 'viewmodels/public', 'Test App', true); router.mapRoute('set/:id', 'viewmodels/set', 'Set'); router.mapRoute('folder/:id', 'viewmodels/folder', 'Folder'); router.mapRoute('api', 'viewmodels/api', 'API Reference'); router.mapRoute('error', 'viewmodels/error', 'Error', false); app.adaptToDevice(); //Show the app by setting the root view model for our application with a transition. if (dataservice.isAuthenticated() === true) { app.setRoot('viewmodels/shell', 'entrance'); router.navigateTo('home'); } else { app.setRoot('viewmodels/public'); router.navigateTo('
Problems
When I launch the application for the first time, I am not authenticated and receive an error message:
Uncaught TypeError: Cannot call method 'lookupRoute' of undefined
The appearance of the string 'router.navigateTo('#/public');' .
Then, when I try to press the login button, I get the same error:
define(['durandal/app', 'durandal/plugins/router', 'services/dataservice'], function (app, router, dataservice) { var publicViewModel = function () { self.logIn = function () { app.setRoot('viewmodels/shell'); router.navigateTo('#/home'); };
But the content is loading correctly. When I go to a specific page by pressing, say in / folder / 2, and then change the url to / folders / 2 (invalid), I get a "route not found" in my log, as expected, but I come across a few other problems:
- I do not get the error page or any errors (it seems to me that I need it for my handleInvalidRoute)
- If I click on another, the URL will not change, and the new content will not be downloaded, again without errors.
I think I'm spoiling somehow, but I'm not sure how to do this. How can I fix the above problems?
Screen:
