-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Impossible to inject providers into Module.provider() when array-style DI-annotations are used #1452
Comments
if you set the compilation level to advanced then you have to tell compiler not to rename $get. this['$get'] should do the trick. This is an issue with configuring the compiler not with angular. |
@mhevery Hmm, I'm probably missing sth but actually this fiddle: http://jsfiddle.net/pkozlowski_opensource/FGkdD/1/ exposes the problem when $get is not renamed (just simulating minifier behavior here). In fact here is another fiddle without any minifications / variables renamed, just using array-style to specify injectables: http://jsfiddle.net/FGkdD/4/ So if I'm not mistaken the problem is really linked to the usage of the array-style of specifying dependencies... But once again, I might be misinterpreting things.... |
I am sorry, but you are not explaining what exactly does not work. Why do On Sun, Oct 14, 2012 at 2:26 PM, Pawel Kozlowski
|
@mhevery
This is not a supported syntax. The only parameters that module.provider accepts is ({string}, {function}), where the function must also have a $get method. The module.provider function ought to accept a ({string}, {array | function}), where the array is a dependency style injection array. Pete |
Ahh, this has nothing to do with compiler. The issue is that provider takes a constructor function or an object instance, but it fails to see if it is an array. This is a real issue. |
Just submitted a fix - I'm guessing we just need to instantiate the array same way we would a normal function. |
`injector.instantiate` is now called for arrays too, instead of only for functions. Closes #1452
`injector.instantiate` is now called for arrays too, instead of only for functions. Closes angular#1452
Getting error 'Uncaught Error: Unknown provider: crudRouteProvider from myApp '
Is this correct way? |
@jintoppy simply write If you ever have a similar question or problem, check this section of our contributing guide to know where you can ask it. We want to keep Github issues for bug reports and feature requests. Thanks! |
Can someone point out why this is not working? (I want to not hardcode day names in a datepicker I'm using) app.provider("ngQuickDateDefaults", function($locale) {
return {
options: {
dayAbbreviations: $locale.SHORTDAY
//dayAbbreviations: ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"]
}
}
} I get (without minifying):
|
@dmbjsn It's because This type of question should be avoided on the angular.js issue tracker, since it's not really an issue with the framework itself. |
@rodyhaddad: You probably meant to write "...is not a constant...". |
@gkalpak indeed, thanks! :) |
try minify, if ok, notify me please. |
@anymone thanks! :) |
Problem description
It is impossible to define a provider that depends on another provider in the minified version of an application. The following code:
will fail with
Uncaught Error: Provider crudRouteProvider must define $get factory method. from myApp
. Here is the jsFiddle: http://jsfiddle.net/pkozlowski_opensource/FGkdD/1/Expected behavior
The unminified version works correctly, here is the jsFiddle: http://jsfiddle.net/pkozlowski_opensource/cHHJJ/
The minified version should behave exactly the same.
The text was updated successfully, but these errors were encountered: