February 2015
Intermediate to advanced
232 pages
4h 40m
English
The view-model is a pure code representation of the data and operations on a UI. It isn't the UI itself. It doesn't have any concept of buttons or display styles. It's not the persisted data model either. It holds the unsaved data the user is working with. View-models are pure JavaScript objects that have no knowledge of HTML. Keeping the view-model abstract in this way lets it stay simple, so you can manage more sophisticated behaviors without getting lost.
To create a view-model, we just need to define a simple JavaScript object:
var vm = {};Then to activate Knockout, we will call the following line:
ko.applyBindings(vm);
The first parameter says which view-model object we want to use with the view. Optionally, we can pass a second ...
Read now
Unlock full access