-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Should $injector#annotate consider the injector's own strictDi option? #12446
Comments
Hi, as you already wrote, I understand that it would be more consistent to make There might be other solutions that also allow for this scenario, but I find the current trade-off reasonable. |
Thanks for reply. return {
invoke: invoke,
instantiate: instantiate,
get: getService,
annotate: function (fn) {
// this strictDi variable comes from createInjector(modulesToLoad, strictDi) method
return createInjector.$$annotate(fn, strictDi);
},
has: function(name) {
return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name);
}
}; In this way, each injector knows your strict di information. Also based on this changes, this line should probably be updated to Keep in mind that I don't have so much knowledge about angular internals, so I'm unsure if this could introduce some drawbacks What do you think? |
Would it be possible to know when calling
This is where the context is important, as there needs to be a very good reason to make such a breaking change |
Sure. I changed my application to use strictDi and after fix the injector errors everything worked fine.
Agree |
I think that the proper way would be to reopen #11728 (or create a PR with a change that implements it) and ask router-ui to use it when calling |
I liked this alternative. I'll work on it. Thanks for your help! |
I was looking the issue tracker and found this #11734. This PR do exactly what you suggested, so I think there is no need to create another. |
Handled by #11734 |
For instance:
In the last example, I also expected an
Error: [$injector:strictdi]
but this option is just ignored and the function is annotated.Using
injector.annotate(foo, true);
make the error threw, but in this case we are duplicating the option, and also there is situations where annotate is being used by some third party library and we cannot control this.The text was updated successfully, but these errors were encountered: