The shell view-model

Shell is the entry point module. It is the module that wraps the other modules. It is loaded just once and has the DOM elements that persist all the time.

To define a view-model, define a simple JavaScript object using the AMD pattern, as done in the following steps:

  1. Define dependencies, that is, the router and the Durandal app:
    define(['plugins/router', 'durandal/app'], function (router, app) {
      return {
        //We complete this in next points
      };
    });
  2. Expose the router method. The router method will give us an object that allows us to show the navigation bar easily.
    return {
      router: router
    };
  3. Expose the search method. This is an optional method. It's part of the starter kit application. It manages the global search.
    return { router: router, ...

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.