0

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

5
  • 1
    Your first example expects a module dataService, your second one defines a service dataService. Do you have a module named dataService? Commented Sep 1, 2015 at 16:19
  • BTW, there is no Service() method in module. Commented Sep 1, 2015 at 16:21
  • @zeroflagL I don't think you understand. In first code I create module app and I declare the dependencie with 'dataService'. In second code, I create 'dataService' service. As in docs, I think ... Commented Sep 2, 2015 at 7:32
  • 1
    angular.module("MyApp" creates the module MyApp which depends on other modules. ui.router is a module, ui.bootstrap is a module. If app in the second example is the same module as app in the first one then you are done. Remove dataService from the first one. Maybe you should look at someone's scores before you decide to write "I don't think you understand". Commented Sep 2, 2015 at 7:49
  • Oh, sorry! I wanted say that "I think that I don't understand you". My english is deplorable, I didn't want offend you. You are right, I had to remove 'dataService' in first example. Thank you very much! Commented Sep 2, 2015 at 9:04

1 Answer 1

1

replace app.Service with app.service.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, this is a grammar error. I correct now. But that error would cause the application doesn't work before minification, and as I mentioned the app works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.