我在文件中添加了一个过滤器,现在我得到了我们都喜欢的注射器错误。我正在尝试对其进行故障排除,我认为这可能与注射顺序有关。您如何声明提供程序/服务/等在注入它们之前必须编译的顺序...
HTML:
<script src="js/app.js"></script>
<script src="js/directives/jokesDirective.js"></script>
<script src="js/filters/jokeFilter.js"></script>
<script src="js/providers/jokeService.js"></script>
<script src="js/controllers/mainController.js"></script>
应用程序.js:
angular.module('jsekoApp', [ 'ui', 'ngRoute', 'ngSlider'])
.config( ... );
主控制器.js:
angular.module('jsekoApp')
.controller('MainController', [ '$scope', 'JokeFilter', 'JokeService', function MainController($scope, JokeFilter, JokeService) {
...
}]);
JokeService 工作正常
jokeFilter 是引发错误的原因 - jokeFilter.js:
angular.module('jsekoApp')
.filter('JokeFilter', [ '$scope', function JokeFilter($scope) {
...
}]);
在主控制器中,我在服务之前声明了过滤器,因为服务需要过滤器。我认为这是正确的。我还在服务之前的 HTML 中声明了过滤器,在 angular 和其他类似的依赖项之后..
完全错误:
Error: [$injector:unpr] Unknown provider: JokeFilterProvider <- JokeFilter
http://errors.angularjs.org/1.2.17/$injector/unpr?p0=JokeFilterProvider%20%3C-%20JokeFilter
at http://127.0.0.1:9000/bower_components/angular/angular.js:78:12
at http://127.0.0.1:9000/bower_components/angular/angular.js:3735:19
at Object.getService [as get] (http://127.0.0.1:9000/bower_components/angular/angular.js:3862:39)
at http://127.0.0.1:9000/bower_components/angular/angular.js:3740:45
at getService (http://127.0.0.1:9000/bower_components/angular/angular.js:3862:39)
at invoke (http://127.0.0.1:9000/bower_components/angular/angular.js:3889:13)
at Object.instantiate (http://127.0.0.1:9000/bower_components/angular/angular.js:3910:23)
at http://127.0.0.1:9000/bower_components/angular/angular.js:7164:28
at link (http://127.0.0.1:9000/bower_components/angular-route/angular-route.js:913:26)
at nodeLinkFn (http://127.0.0.1:9000/bower_components/angular/angular.js:6607:13) <div class="container-fluid ng-scope" ng-view=""> angular.js:9899
(anonymous function) angular.js:9899
(anonymous function) angular.js:7246
nodeLinkFn angular.js:6610
compositeLinkFn angular.js:6011
publicLinkFn angular.js:5916
boundTranscludeFn angular.js:6030
controllersBoundTransclude angular.js:6628
update angular-route.js:871
Scope.$broadcast angular.js:12797
(anonymous function) angular-route.js:552
wrappedCallback angular.js:11408
wrappedCallback angular.js:11408
(anonymous function) angular.js:11494
Scope.$eval angular.js:12518
Scope.$digest angular.js:12330
Scope.$apply angular.js:12622
done angular.js:8234
completeRequest angular.js:8439
xhr.onreadystatechange