나는 예제를 따라 갔지만 분명히 리소스 프로토 타입에 사용자 지정 메서드를 추가 할 때 잘못된 것이 있습니다. 컨트롤러에서
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();
할 수 있지만
$ 자원의 프로토 타입에 추가하는 예에 대한 링크를 제공 할 수 있습니까? 나는 그걸 본 적이 기억이 없다. –