You call the setShipping()
function, shown in Listing 28.26, when the user clicks the Continue to Billing button in the cart view. The shipping information needs to be updated in the database to ensure that it is persistent when the customer leaves the website. You call an $http POST
method to the /customers/update/shipping
route. The POST
includes the parameter {updatedShipping:$scope.customer.shipping[0]}
in the body. If the request is successful, the view switches to billing.html
; otherwise, an alert appears.
094 $scope.setShipping = function(){
095 $http.post('/customers/update/shipping',
096 { updatedShipping: $scope.customer.shipping[0] })
097 .success(function(data, status, headers, config) {
098 $scope.content = '/static/billing.html';
099 })
100 .error(function(data, status, headers, config) {
101 $window.alert(data);
102 });
103 };
18.188.115.155