Angular function is not using explicit annotation and cannot be invoked in strict mode

☆樱花仙子☆ 提交于 2019-12-08 04:57:27

You enabled strict mode, in order to detect where you forgot to use $inject or the array notation to make sure your code can be safely minified.

The message tells you that you failed to properly annotate your injectable functions. Note that, in addition to that, your code doesn't make much sense:

  • the function passed to run() is supposed to take injectable services as argument, and all its arguments except $window are not services.
  • the function passed to $on() is not an injectable function. So passing it $windows makes no sense. The router will only invoke it with the 4 first arguments.

So, your code should be:

.run(['$rootScope', '$window', function($rootScope, $window) {
    $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState) { 

I would strongly advise to stop annotating your injectable functions by hand, and to use ng-annotate to do that for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!