DevT
DevT

Reputation: 1511

Angular Unknown Provider after minification

I'm having problems after the minification of my angular code, like $injector:modulerr and similar. I'm using a custom module, have a look here https://github.com/grevory/angular-local-storage/blob/master/src/angular-local-storage.js, that is injected in this way:

var app = angular.module('MyNewApp', ['LocalStorageModule'] );

app.config(function(localStorageServiceProvider){
  localStorageServiceProvider.setPrefix('myNewApp');
  localStorageServiceProvider.setStorageType('sessionStorage');
})

After the minification it doesn't work, so I'm trying something like this below to fix:

app.config(["localStorageService", function(localStorageServiceProvider){
  ..
})

And

angular.module('MyNewApp', [] )
// and also .module('LazyDogzApp', ['LocalStorageModule'] )
   .config(['localStorageService', function(localStorageServiceProvider)
   ...
   }]);

but I alway get an error $injector:unpr Unknown Provider: localStorageService

Any idea? Thanks

Upvotes: 1

Views: 766

Answers (2)

Kirill Husiatyn
Kirill Husiatyn

Reputation: 828

Also, if you are using gulp, add ng-annotate

Upvotes: 1

Rodson
Rodson

Reputation: 576

Try this.

app.config(["localStorageServiceProvider", function(localStorageServiceProvider){
   ...
})

Upvotes: 1

Related Questions