gpt4 book ai didi

javascript - AngularJS-错误 : $injector:unpr Unknown Provider

转载 作者:行者123 更新时间:2023-11-28 05:40:46 33 4
gpt4 key购买 nike

请帮帮我!

我的项目使用 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,谢谢

最佳答案

您的错误消息表明 Quotes 工厂依赖于 osme 提供程序 a。但我在提供的代码中看不到这种依赖性。显示真实代码或修复真实代码中的依赖关系。

关于javascript - AngularJS-错误 : $injector:unpr Unknown Provider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38939955/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com