請幫幫我!
我的項目中使用角度,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,謝謝
確保文件順序正確 –
爲什麼你使用兩個不同的模塊? –
請發佈您的index.html文件,在其中設置了一些視圖。確保文件的順序(或包含的文件的編號)是正確的。 –