I'm a novice at Durandal but familiar with mvc4. I'm attempting to port an existing application that heavily uses knockout to a SPA framework.
I've been able to get the standard View / ViewModel convention working with the information from this post: https://stackoverflow.com/a/15636715/1693081
I'd like to extend this to a feature based structure because each page has multiple reusable components, I'd like to set up my application directory as follows:
App
|
|--- Pages
| |
| |---Shell
| | |
| | |---Shell.chtml
| | |---Shell.js
| | |---web.config
| |
| |---Dashboard
|
|---Dashboard.chtml
|---Dashboard.js
|--web.config
I thought it would be as simple as commenting out viewLocator.userConvention() and added a new route but this throws a failed to load root module exception.
from my main.js:
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();
//Show the app by setting the root view model for our application with a transition.
app.setRoot('pages/shell/shell', 'entrance');
});
from my Routeconfig.cs:
routes.MapRoute(
name: "Durandal Page Level Views",
url: "App/Pages/{viewFolder}/{viewName}.html",
defaults: new { controller = "DurandalView", action = "Get" }
);
Am I missing something obvious? The documentation for Durandal suggests that their defaults aren't best for a large application but doesn't give me an idea as to how to solve it out of the box.
Thanks!
I had a work around for this. It turns out that dropping the web.config interferes with the ability to load the js files in each directory. I ended up splitting each page into model and view model folders.