拜托,帮助我!
我的项目使用Angular,MVC6
这是我开始调试时的错误
> angular.js:13920 Error: [$injector:unpr]
> http://errors.angularjs.org/1.5.8/$injector/unpr?p0=aProvider%20%3C-%20a%20%3C-%20Quotes
> at Error (native)
> at http://localhost:55050/lib/angular/angular.min.js:6:412
> at http://localhost:55050/lib/angular/angular.min.js:43:174
> at Object.d [as get] (http://localhost:55050/lib/angular/angular.min.js:40:432)
> at http://localhost:55050/lib/angular/angular.min.js:43:236
> at d (http://localhost:55050/lib/angular/angular.min.js:40:432)
> at e (http://localhost:55050/lib/angular/angular.min.js:41:158)
> at Object.invoke (http://localhost:55050/lib/angular/angular.min.js:41:243)
> at Object.$get (http://localhost:55050/lib/angular/angular.min.js:39:142)
> at Object.invoke (http://localhost:55050/lib/angular/angular.min.js:41:456)
这是我的代码:
文件app.js:
(function () {
'use strict';
angular.module('myQuotesApp', [
'quotesService'
]);
})();
quotesController.js
(function () {
'use strict';
angular
.module('myQuotesApp')
.controller('quotesController', quotesController);
quotesController.$inject = ['$scope', 'Quotes'];
function quotesController($scope, Quotes) {
$scope.quotes = Quotes.query();
}
})();
quotesService.js
(function () {
'use strict';
var quotesService = angular.module('quotesService', ['ngResource']);
quotesService.factory('Quotes', function ($resource) {
return $resource('/api/quotes/', {}, {
query: { method: 'GET', param: {}, isArray: true }
});
});
})();
这是我第一次使用angularJS,谢谢
答案 0 :(得分:0)
您的错误消息指出Quotes
工厂依赖于osme提供程序a
。但我无法在提供的代码中看到依赖性。在真实代码中显示真实代码或修复可靠性。
答案 1 :(得分:0)
根据您的评论,您应该将依赖项指定为字符串。
E.g。
quotesService.factory('Quotes', ['$resource', function ($resource) {
return $resource('/api/quotes/', {}, {
query: { method: 'GET', param: {}, isArray: true }
});
}])
等等。