ng-strict-di无法识别'ngInject'

时间:2018-04-17 05:48:58

标签: ruby-on-rails angularjs ng-annotate

我正在使用带有AngularJS 1.5的Rails 4.0和ng-annotate gem。我注意到当我使用'ng-strict-di'强制你注释AngularJS中的所有直接注入时,我发现Rails抱怨有“ngInject”到位的模块。

例如;这是我的Angular应用程序控制器

ApplicationController = (
  $scope, $timeout,
  hotkeys
  ShortcutService) ->
  "ngInject"
<SNIP>

我在模板中启用了ng-strict-di

<html ng-app='paisApp' ng-strict-di>

当我在开发模式下运行我的应用程序时,我在控制台中出错;

Error: [$injector:strictdi] ApplicationController is not using explicit annotation and cannot be invoked in strict mode
http://errors.angularjs.org/1.5.11/$injector/strictdi?p0=ApplicationController
minErr/<@http://localhost:3000/assets/angular/angular.self.js?body=1:69:12
annotate@http://localhost:3000/assets/angular/angular.self.js?body=1:4006:17
injectionArgs@http://localhost:3000/assets/angular/angular.self.js?body=1:4733:21
instantiate@http://localhost:3000/assets/angular/angular.self.js?body=1:4784:18
$controller@http://localhost:3000/assets/angular/angular.self.js?body=1:10608:18
controllerDecorator/<@http://localhost:3000/assets/app/bower_components/angular-material-data-table/dist/md-data-table.self.js?body=1:321:12
compile/<@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:9781:46
bind/<@http://localhost:3000/assets/angular/angular.self.js?body=1:1260:15
invokeLinkFn@http://localhost:3000/assets/angular/angular.self.js?body=1:10153:9
nodeLinkFn@http://localhost:3000/assets/angular/angular.self.js?body=1:9552:11
compositeLinkFn@http://localhost:3000/assets/angular/angular.self.js?body=1:8811:13
publicLinkFn@http://localhost:3000/assets/angular/angular.self.js?body=1:8691:30
lazyCompilation@http://localhost:3000/assets/angular/angular.self.js?body=1:9048:16
updateView@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:9719:38
configUpdatedCallback@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:9663:25
configureUIView@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:5640:17
ViewService.prototype.sync@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:5645:9
activateViews@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:6273:5
invokeCallback@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:1580:20
TransitionHook.prototype.invokeHook@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:1592:26
TransitionHook.runAllHooks/<@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:1719:48
TransitionHook.runAllHooks@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:1719:9
transitionSuccess@http://localhost:3000/assets/angular-ui-router/angular-ui-router.self.js?body=1:3432:13
processQueue@http://localhost:3000/assets/angular/angular.self.js?body=1:16697:28
scheduleProcessQueue/<@http://localhost:3000/assets/angular/angular.self.js?body=1:16713:27
$eval@http://localhost:3000/assets/angular/angular.self.js?body=1:17995:16
$digest@http://localhost:3000/assets/angular/angular.self.js?body=1:17809:15
$apply@http://localhost:3000/assets/angular/angular.self.js?body=1:18103:13
done@http://localhost:3000/assets/angular/angular.self.js?body=1:12083:36
completeRequest@http://localhost:3000/assets/angular/angular.self.js?body=1:12292:7
requestLoaded@http://localhost:3000/assets/angular/angular.self.js?body=1:12220:9
 <div id="wrapper" ui-view="" class="ng-scope" data-ng-animate="1">
angular.self.js:14200:18

如果我手动注释这个,那么该文件的错误消失了。我有很多angularJS文件,所以我不想为每个文件做这个。

更新

我正在运行我的服务器,NG_FORCE = true就像这样;

NG_FORCE=true RAILS_ENV=development bundle exec rails s

0 个答案:

没有答案
相关问题