July 2017
Intermediate to advanced
374 pages
8h
English
In order to get the data from the RESTful API, we will use AJAX. Observables keep a track of the changes made on the data and reflect them, automatically, on all the locations where it is used and defined by ViewModel.
By using Observables, it becomes very easy to make the UI and ViewModel communicate dynamically.
Let's create a file named app.js, which has Observables declared, inside the static directory with the following code--if the directory does not exist, create it:
function User(data) { this.id = ko.observable(data.id); this.name = ko.observable(data.name); this.username = ko.observable(data.username); this.email = ko.observable(data.email); this.password = ko.observable(data.password); } function ...