Feeling a bit confused by what should be a simple task. I am currently working on enhancing an Angular service by adding some new methods. Initially, the service was only making a single $resource call to my API. The additional methods I am incorporating are basic functions that save and retrieve a local object:
'use strict';
angular.module('gameApp')
.factory('searchService', ['$resource',
function($resource) {
var base = '/api/search?query=:query';
var latestResults = {};
return $resource(base, {}, {
getResults: {method: 'GET', url: base}
}),
saveLatest: function(results) {
latestResults = results;
},
getLatest: function() {
return latestResults;
}
}]);
It appears that the structure above is incorrect, particularly in relation to the saveLatest
and getLatest
functions.