Created
November 5, 2014 23:33
-
-
Save pc-pdx/1a5e408ee691bf956763 to your computer and use it in GitHub Desktop.
CsWebApp.core.dataservice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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