I'm trying to create a custom service which pulls the list of all defined statuses from the server for use in forms, so far I have:
SimpleTaskApp.factory('storyStatus', function($http) {
var data = null;
var promise = $http({
url: '/story-status/',
method: 'GET'
}).success(function (resp) {
data = resp;
});
return {list: data }};
});
I understand this won't work since $http is asynchronous, however I have no desire to run the request more than once. I'd like to treat it as a static variable in effect, so if ever storyStatus.list is called, it should check whether it is empty and then attempt to populate itself.