admin管理员组

文章数量:1312702

I'm trying to add angular-translate to my angular app. I followed this simple quick start: , but my app won't bootstrap, giving me the following error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr] Failed to instantiate module pascalprecht.translate due to: Error: [$injector:nomod] Module 'pascalprecht.translate' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

My index.html file is properly including angular-translate like so:

<script src="bower_ponents/angular-translate/angular-translate.js"></script>

Any clue why this could be happening?. I'd really appreciate the help.

UPDATE

Here's part of my app.js to clarify things a bit:

var app = angular.module('myApp', [
  'ngAnimate',
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngTouch',

  // 3rd party modules.
  'ui.router',
  'restangular',
  'angular.filter',
  'ui.bootstrap',
  'pascalprecht.translate',


  // Custom modules.
  'myApp.config'
])
.
.
.

I'm trying to add angular-translate to my angular app. I followed this simple quick start: https://angular-translate.github.io/docs/#/guide, but my app won't bootstrap, giving me the following error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr] Failed to instantiate module pascalprecht.translate due to: Error: [$injector:nomod] Module 'pascalprecht.translate' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

My index.html file is properly including angular-translate like so:

<script src="bower_ponents/angular-translate/angular-translate.js"></script>

Any clue why this could be happening?. I'd really appreciate the help.

UPDATE

Here's part of my app.js to clarify things a bit:

var app = angular.module('myApp', [
  'ngAnimate',
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngTouch',

  // 3rd party modules.
  'ui.router',
  'restangular',
  'angular.filter',
  'ui.bootstrap',
  'pascalprecht.translate',


  // Custom modules.
  'myApp.config'
])
.
.
.
Share Improve this question edited May 15, 2015 at 19:47 Luis Crespo asked May 15, 2015 at 19:38 Luis CrespoLuis Crespo 1,6301 gold badge20 silver badges33 bronze badges 7
  • As it says, If registering a module ensure that you specify the dependencies as the second argument. -- so, did you? I.e. could you show a bit more of your code, if you did specify dependencies correctly. – jmustonen Commented May 15, 2015 at 19:41
  • yep I did specify the 'pascalprecht.translate' dependency. I'm updating the question to show a bit of my app.js – Luis Crespo Commented May 15, 2015 at 19:43
  • Ok, things do look to be ok.. did you already check with your browser's network monitor, that the angular-translate.js file is indeed loading correctly? – jmustonen Commented May 15, 2015 at 19:52
  • Yes. The browser is indeed loading the file correctly. angular-translate.js is in the loaded resources. – Luis Crespo Commented May 15, 2015 at 19:55
  • Ok, seems quite weird. Was everything working until you introduced angular-translate? What if you now remove angular-translate dependency and the angular-translate.js from loading? – jmustonen Commented May 15, 2015 at 20:02
 |  Show 2 more ments

3 Answers 3

Reset to default 2

I had faced same problem, resolved it by adding below entries. Also remeber to put these .js files in correct order too.

files : [
         '../js/libs/angular.js',    
          '../libs/angular-route.js', 
          '../angular-translate.min.js',
          '../libs/angular-translate-loader-url.js',

Hope, this helps.

Regards, Aditi.

It was failing because of another dependency throwing an error, specifically jquery.easy-pie-chart. I wasn't using that dependency at all so I removed it and angular-translate started working without a problem.

I had other modules depending on the translation module, so I was able to fix this error by loading it right after loading angular itself.

本文标签: javascriptangulartranslate module 39pascalprechttranslate39 not foundStack Overflow