Using the router
While technically an optional plugin, I don't imagine any real-world SPAs will do without the use of the router. While SammyJS ties a URL fragment to a function, Durandal's router ties the URL directly to a module ID. The module can return either a singleton or a constructor, and will be used to bind the view using the standard composition system.
Configuring the router
Let's start configuring the router:
- Route configuration is pretty straightforward. Here is the
shell
module with router configuration for theContact
application:define(['plugins/router', 'knockout', 'durandal/app'], function (router, ko, app) { return { title: app.title, router: router, activate: function() { router.map([ { route: '', moduleId: 'contacts/list', title: 'Contacts', nav: true }, { route: 'contacts/new', moduleId: 'contacts/edit', title: 'New Contact',...