I have a quiz type application with a factory that gets a list of questions from the server:
xoryApp.factory('questionService', function($http) {
return {
qdata : function(callback) {
$http.get('/static/question.json').success(callback);
}
};
});
Then I call this factory in my controller like this:
questionService.qdata(function(results) {
$scope.qdata = results;
});
Then I switch back and forth between question and answer partial views as I loop through the questions. The problem is that every time the question view loads, it re-loads the factory json from the server. But I want it to only do that once when I load the app, not every time I load a partial view that uses that controller.
What is the way that you achieve that in angular?
Thanks