最佳答案
我试图“定制”mongolab 示例以适应我自己的 REST API。现在我遇到了这个错误,我不知道自己哪里做错了:
Error: Unknown provider: ProductProvider <- Product
at Error (unknown source)
at http://localhost:3000/js/vendor/angular.min.js:28:395
at Object.c [as get] (http://localhost:3000/js/vendor/angular.min.js:26:180)
at http://localhost:3000/js/vendor/angular.min.js:28:476
at c (http://localhost:3000/js/vendor/angular.min.js:26:180)
at d (http://localhost:3000/js/vendor/angular.min.js:26:314)
这是我的控制器:
function ProductListCtrl($scope, Product) {
$scope.products = Product.query();
}
这就是模块:
angular.module('productServices', ['ngResource']).
factory('Product', ['$resource', function($resource){
var Product = $resource('/api/products/:id', { }, {
update: { method: 'PUT' }
});
return Product;
}]);