Routing the project – the shell view-model

Durandal gives us the possibility of managing the routes in our project. We are going to split different parts of our project into pages. That will give a better user experience because we will be focused on just one task at a time.

We will split the app into four parts:

  • The catalog
  • The cart
  • The order
  • The product CRUD

These parts will contain more or less the same code we built in the Knockout application. Sometimes we will need to adapt small pieces of code.

To create these new routes, we will open the shell.js file and update the router:

router.map([ { route: ['','/','catalog'], title:'Catalog', moduleId: 'viewmodels/catalog', nav: true }, { route: 'new', title:'New product', moduleId: 'viewmodels/new', nav: ...

Get KnockoutJS Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.