robBerto
robBerto

Reputation: 196

Error in Dependency Injection when I try minify angular app

I have done a web application based in ASP MVC and angularJS, and everything works fine. Now, I want deploy it. In my bundleConfig I have put BundleTable.EnableOptimizations = true; to minified my scripts.

When I launch the app get a error:

Module 'dataService' is not available! You either misspelled...

In docs I have seen an interesting thing (it fits to error):

Careful: If you plan to minify your code, your service names will get renamed and break your app.

As docs suggests I use Inline Array Annotation. My code is:

app = angular.module("MyApp", ['ui.router', 'ui.bootstrap', 'kendo.directives', 'dataService', 'LoginFactory', 'globalService']);

in module dataService is:

app.service('dataService', ['$http', function($http) {
  // service logic
}]);

I thought that would fix the error, but not.

PS: I have seen 3 differents methods of injection dependencies and I have used all. In example I use that because in docs is marked like preferred

Upvotes: 0

Views: 140

Answers (1)

Mudasser Ajaz
Mudasser Ajaz

Reputation: 6257

replace app.Service with app.service.

Upvotes: 1

Related Questions