Skip to content

Instantly share code, notes, and snippets.

@pc-pdx
Created November 5, 2014 23:33
Show Gist options
  • Save pc-pdx/1a5e408ee691bf956763 to your computer and use it in GitHub Desktop.
Save pc-pdx/1a5e408ee691bf956763 to your computer and use it in GitHub Desktop.
CsWebApp.core.dataservice
(function () {
'use strict';
angular
.module('CsWebApp.core')
.factory('dataservice', dataservice);
function dataservice($http) {
var isPrimed = false;
var accountData; //create instance of accountData
var service = {
getAccountData: getAccountData
};
return service;
function getAccountData() {
// check to see if accountData has been filled, else give 'em back the instance
if (isPrimed)
return accountData;
//we fill it once
return $http.get('/Payment/PayYourBill/GetModel')
.then(getAccountComplete)
.catch(function (message) {
//handle it!
});
}
function getAccountComplete(data, status, headers, config) {
isPrimed = true;
//SUGGESTION use _underscore.js _.isEmpty(data['AccountData']);
if (data['AccountData'].length == 0) {
return null; //?
}
//do your ProcessingInstruction stuffs here to return a sharable data source.
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment