如果我不注入ValuesResource
控制器welcomeCtrl
,应用程序就可以工作。我已阅读错误文档,但找不到问题。
app.factory('ValuesResource', ['$resource',
function($resource) {
return $resource('http://localhost:53257/api/Value/:id', { id: '@id' });
}]);
app.controller('welcomeCtrl', ['$scope', '$rootScope', '$routeParams', 'ValuesResource',
function ($scope, $rootScope, $routeParams, ValuesResource) {
$scope.getvalues = function() {
$scope = ValuesResource.query();
}
}]);
错误:
Error: [$injector:unpr] http://errors.angularjs.org/1.4.8/$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-%20ValuesResource
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:6:416
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:41:121
at Object.d [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:39:92)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:41:195
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:39:92)
at Object.e [as invoke] (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:39:362)
at Object.$get (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:37:311)
at Object.e [as invoke] (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:39:394)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js:41:224 <div ng-view="" class="ng-scope">