The second feature is about retrieving and displaying the address details. To implement this feature, we will:
Let's get started by modifying the model we created previously to capture address details. First, create a generic function to construct the address model. The address model should have attributes that you want to capture and display, such as street number and name. Here is our implementation:
/* generic model for address */ var AddressModel = function() { this.location = ko.observable(); this.streetNumber = ko.observable(); this.streetName = ko.observable(); this.city = ko.observable(); this.state = ko.observable(); this.postCode = ko.observable(); this.country = ko.observable(); };
Note the use of observables in AddressModel
. This will allow you to do two-way binding between...