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:
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 }; });
Expose the
router
method. Therouter
method will give us an object that allows us to show the navigation bar easily.return { router: router };
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, search: function() { //easy way to show a message box in Durandal app.showMessage('Search not yet implemented...'); }, };
Expose the
activate
method. This is an important method in Durandal view-models. Theactivate
method...