【发布时间】:2017-06-18 14:01:00
【问题描述】:
如标题中所述,我收到以下错误: 未知提供者:$resourceProvider
具体在 Microsoft Edge 的控制台中:
SCRIPT438: Object doesn't support property or method 'info'
angular-resource.js (444,1)
Error: [$injector:unpr] Unknown provider: $resourceProvider <- $resource <- Review
http://errors.angularjs.org/1.6.1/$injector/unpr?p0=%24resourceProvider%20%3C-%20%24resource%20%3C-%20Review
at Anonymous function (https://code.angularjs.org/1.6.1/angular.js:4630:13)
at getService (https://code.angularjs.org/1.6.1/angular.js:4783:11)
at Anonymous function (https://code.angularjs.org/1.6.1/angular.js:4635:13)
at getService (https://code.angularjs.org/1.6.1/angular.js:4783:11)
at injectionArgs (https://code.angularjs.org/1.6.1/angular.js:4807:9)
at invoke (https://code.angularjs.org/1.6.1/angular.js:4834:7)
at enforcedReturnValue (https://code.angularjs.org/1.6.1/angular.js:4676:7)
at invoke (https://code.angularjs.org/1.6.1/angular.js:4842:9)
at Anonymous function (https://code.angularjs.org/1.6.1/angular.js:4636:13)
at getService (https://code.angularjs.org/1.6.1/angular.js:4783:11) <div class="ng-scope" ng-view="">
angular.js (14328,11)
我在谷歌上搜索了错误并遇到了多个解决方案,但似乎我仍然做错了什么,即使在尝试实施上述解决方案时...
index.html:`
<!DOCTYPE html>
<html ng-app="VideogameReviewsApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello AngularJS</title>
</head>
<body>
<div ng-view></div>
<script src="https://code.angularjs.org/1.6.1/angular.js"></script>
<script src="https://code.angularjs.org/1.6.1/angular-route.js"></script>
<script src="https://code.angularjs.org/1.6.4/angular-resource.js"></script>
<script src="js/app.js"></script>
</body>
</html>
为简单起见,我在 app.js 中包含了所有代码:
'use strict';
var VideogameReviewsApp = angular.module('VideogameReviewsApp', ['ngRoute','ngResource']).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/', { controller: ReviewCtrl, templateUrl: 'review.html' }).
otherwise({ redirectTo: '/' });
}]);
VideogameReviewsApp.factory('Review', function ($resource) {
return $resource('http://localhost/videogamereviews/review/:id', { id: '@id' }, { update: { method: 'PUT' } });
});
var ReviewCtrl = function ($scope,Review) {
alert("mop")
$scope.items = Review.get();
};
非常感谢您的帮助!
阿什利
【问题讨论】:
标签: javascript angularjs