我正在尝试注入我的服务,但我不断收到 unpr 错误。我遵循了 angularjs 文档,但似乎没有解决它。我不知道为什么这个错误不断出现。
我的服务
(function(){
'use strict';
angular
.module('omicron.projects.services')
.factory('Projects', Projects);
Projects.$inject = ['$resource', '$scope'];
/**
*
* @param $resource
* @constructor
*/
function Projects($resource){
return $resource('/api/projects/:userid', {}, {
get: {method: 'GET'},
query: {method: 'GET'},
update: {method: 'PUT'},
save: {method: 'POST'},
delete: {method: 'DELETE'}
},{
stripTrailingSlashed: false
});
}
})();
我的控制器,调用服务
(function() {
'use strict';
angular
.module('omicron.projects.controllers')
.controller('ProjectController', ProjectController);
ProjectController.$inject = ['$scope', 'Projects'];
function ProjectController($scope, Projects) {
var vm = this;
vm.projects = Projects.get({userid: $scope.user}, function(){
console.log(projects);
});
}
})();
我的模块定义
/**
* Created by shahab on 15-09-03.
*/
(function(){
'use strict';
angular
.module('omicron.projects', [
'omicron.projects.controllers',
'omicron.projects.directives',
'omicron.projects.services'
]);
angular
.module('omicron.projects.services', ['ngCookies', 'ngResource']);
angular
.module('omicron.projects.controllers', []);
angular
.module('omicron.projects.directives', []);
})();
我的错误:
错误:[$injector:unpr] 未知提供者:$resourceProvider <- $resource <- Projects