I use the AngularJS service to store data from several pages to be presented together. See code below.
In my Chrome console, if I observe checkoutData.shipping , I return the correct data object. If I observe checkoutData.data , I get an empty object where the delivery property is empty.
They should point to the same object, right? Why will it work with .shipping and not use .data? The reason it is configured this way is because the delivery page only cares about delivery, and the last page requires everything in .data.
(function() { angular.module('app').factory('checkoutData', [function() { var data = { carrierId: null, serviceTypeId: null, shippingCost: {}, billingOptionId: null, shipping: {}, billing: {}, cart: null }; var inputForms = {}; var options = { shippingOptions: null, billingOptions: null, selectedShippingOption: null }; var staticContent = { billing: {}, cart: {}, shipping: {} }; return { data: data, shipping: data.shipping, inputForms: inputForms, cart: data.cart, billingOptionId: data.billingOptionId, billingOptions: options.billingOptions, carrierId: data.carrierId, serviceTypeId: data.serviceTypeId, shippingOptions: options.shippingOptions, staticContentBilling: staticContent.billing, staticContentCart: staticContent.cart, staticContentShipping: staticContent.shipping, selectedShippingOption: options.selectedShippingOption, setValid: function(formName, valid) { inputForms[formName].valid = valid; }, initializeForm: function(formName) { inputForms[formName] = {}; }, formInitialized: function (formName) { return inputForms[formName] != null; } } }]); })();