私は例を辿ってきましたが、リソースのプロトタイプにカスタムメソッドを追加するときに間違っているようです。コントローラで
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;
})
私は$scope.products = Product.all();
を行うが、私はあなたが実際にまだインスタンスを持っていないので、それはだと思う
$リソースのプロトタイプに追加する例のリンクを提供できますか?私はそれを見て覚えていない。 –