0
votes

I am using angularjs-translate but getting Error: [$injector:modulerr] http://errors.angularjs.org/1.3.13/$injector/modulerr?p0=pharma error, below is my code for reference

var app = angular.module('pharma',['pascalprecht.translate']);

app.config('$translateProvider',function($translateProvider){


     $translateProvider.translations('en', {
         "TITLE":"Angular way!"
    });
     $translateProvider.translations('fr', {
         "TITLE":"angulaire !"
    });
    $translateProvider.preferredLanguage('en');


});


app.controller('TranslateController',  function($translate, $scope) {
  $scope.changeLanguage = function (langKey) {
    $translate.use(langKey);
  };
});
1
Code seems OK, did you include the JS lib in your index.html ? - Jscti
These are the lib files included <script src="library/js/vendor/angular.js"></script> <script src="library/js/vendor/angular-translate.js"></script> <script src="library/js/vendor/jquery.js"></script> - Rash

1 Answers

0
votes

Check:

var app = angular.module('pharma',['pascalprecht.translate'])
  .config(function($translateProvider){ 
     $translateProvider.translations('en', {
         "TITLE":"Angular way!"
     });
     $translateProvider.translations('fr', {
         "TITLE":"angulaire !"
    });
    $translateProvider.preferredLanguage('en');
 });

 app.controller('TranslateController',  ['$translate', '$scope', function($translate, $scope) {
      $scope.changeLanguage = function (langKey) {
        $translate.use(langKey);
      };
 }]);