Defining the app.js file
When we defined the RequireJS configuration, we said that the entry point will be the app.js
file. The following are the steps to create the app.js
file:
Create the
app.js
file.Set the array of dependencies. Map these dependencies as arguments in the function. There are some files that just execute code and they return an undefined value. You don't need to map these files if they are at the end of the list of dependencies.
define([ //LIBRARIES 'bootstrap', 'knockout', 'koAmdHelpers', 'ko.validation', 'icheck', //VIEWMODEL 'viewmodel', //MOCKS 'mocks/product', 'mocks/order', //COMPONENTS 'custom/components', //BINDINGS 'custom/koBindings', //EVENTS 'events/cart' ], function(bs, ko, koValidation, koAmdHelpers, 'iCheck', 'ViewModel) { });
Now define the body of the module. It will initialize global configurations and global behaviors. Finally, it will return the view-model:
define([...],function(...){ //ko External Template Settings...