Angular itkn error caused by directives defined using an external array function

I am using Angular 1.3.15, also tried 1.2.28, as well as Angular bootstrap. Last night, after updating Chrome to v42.0.2311.90, I suddenly began to detect tons of Angular itkn errors:

Error: [$injector:itkn] Incorrect injection token! Expected service name as string, got function () http://errors.angularjs.org/1.3.15/$injector/itkn?p0=function%20() at REGEX_STRING_REGEXP (angular.min.js?bust=undefined:63) at Object.invoke (angular.min.js?bust=undefined:4189) at angular.min.js?bust=undefined:6525 at forEach (angular.min.js?bust=undefined:323) at Object.<anonymous> (angular.min.js?bust=undefined:6523) at Object.invoke (angular.min.js?bust=undefined:4204) at Object.enforcedReturnValue [as $get] (angular.min.js?bust=undefined:4056) at Object.invoke (angular.min.js?bust=undefined:4204) at angular.min.js?bust=undefined:4021 at Object.getService [as get] (angular.min.js?bust=undefined:4162) 

This did not happen before the Chrome update, but I think I can’t say that this is exactly related.

After scrolling, I found that any directives defined as follows:

  .directive('modalTransclude', function () { return { // directive code }; }) 

itkn error. I have console.logged key in the $inject test in Angular, and it returns a function of the directive itself, and not just strings like this were clearly intended.

I found that wrapping a function in an array, even without any lines defining the injections, solves the problem:

  .directive('modalTransclude', [function () { return { // directive code }; }]) 

However, this error does not occur on the Angular bootstrap site, and I tried this on both versions of Angular versions 1.3 and 1.2.

I will continue to search for any reasons that are unique to my application, but does anyone know what causes this?

+7
angularjs angular-bootstrap
source share
4 answers

If you have the ng-inspector.org extension installed on chrome, this may be the reason. Just disable the ng-inspector browser extension.

I do not know the exact reasons why it does not work with the ng inspector at the moment. If someone has time to look at this, it would be nice to present an error for the project involved (I suspect that he is an inspector himself).

+7
source share

This is really a problem that appeared with version 0.5.9 ng-inspector (I accompany it) that was released yesterday. I am already working on a solution for this and will release it soon.

I am very sorry for the inconvenience = (

Edit: Just published v0.5.10 should fix this problem. If you encounter additional difficulties, feel free to open the problem at https://github.com/rev087/ng-inspector/

+2
source share

It should work without defining square brackets. The only reason for square brackets is to minimize js.

Directular Link

0
source share

Yesterday I reported the same release in the gigub ng-inspector registry, and there is already an attempt to fix it (it still does not check whether it works or not) https://github.com/rev087/ng-inspector/issues/95 # issuecomment-93423284

0
source share

All Articles