provider $get minification
bugwelle opened this issue · 5 comments
Hello,
I'm using grunt-ngmin
, but I'm having a question on minification:
I have an own provider function and in this provider there has to be a .$get() function like this:
this.$get = function ($rootScope) {
// do something with $rootScope...
};
But after ngmin
minification the code isn't unchanged and after uglify-js
has done it's minification, too, I get an error (Unknown provider: eProvider <- e <- ...
).
Is there a way (or a workaround) to avoid this? :)
Thanks,
Andre
ngmin
should support annotating this.$get
. Try updating if you're on an old version.
I updated to latest version. Still doesn't work, but I know why. This is my testing code:
angular.module('testApp', []).provider('testProvider', function ($timeout) {
var self = this;
self.$get = function ($rootScope) {
var test = $rootScope.something;
return function () {
return test;
};
};
});
output
angular.module('testApp', []).provider('testProvider', [
'$timeout',
function ($timeout) {
var self = this;
self.$get = function ($rootScope) {
var test = $rootScope.something;
return function () {
return test;
};
};
}
]);
When I change self.$get
to this.$get
, it works ;)
@archer96 glad to see you found the problem. :)
I can't support arbitrary aliases without making this task significantly more complex. I think using fn.bind()
in conjunction with this.$get
should be fine for most cases.
If anyone has a compelling reason otherwise, I'd love to hear it. Otherwise, I think this can be closed.
I use always a reference to this
. :)
But that was only a small change. Could you add a sentence to References like "Don't make references to this
" or anything like that?
Thanks,
Andre
Does ngmin support prototype.$get? I'm having problems with that.