I've followed the examples but apparently something is wrong when adding a custom method to the resource's prototype.
app.factory('Product',function ($resource,$cacheFactory) {
var Product = $resource('/the/url/:id', {id: '@id'}),
cache = $cacheFactory('Product'),
products;
Product.prototype.all = function(){
products = cache.get('all');
if(typeof products == 'undefined'){
products = Product.query();
cache.put('all',products);
}
return products;
};
return Product;
})
In the controller I do $scope.products = Product.all(); but I get
TypeError: Object function Resource(value) {
copy(value || {}, this);
} has no method 'all'