I am building a node/angular app. And I am not used to javascript. I made a service for all my static list obects. I am trying to make this code as generic as possible. I think I can improve it more. Here is what I have for the moment (I put only 2, but I will have many more):
function returnSolList (n, $resource) {
return $resource(n+'/', {}, {'query' : {method : 'GET', cache : true, isArray:true } });
}
mod.factory('Cities', ['$resource', function($resource) {return returnSolList('cities', $resource);}]);
mod.factory('Boites', ['$resource', function($resource) {return returnSolList('boites', $resource);}]);
I think I could do better with something maybe by declaring my services in a list ['Cities', 'Boites'] and then loop to build the factory. Also there is redundance in the $resource that I would like to get rid of.
But I am not sure how to do it.