Skip to content Skip to sidebar Skip to footer

Angular-translate Unknown Provider

Im using angular translate in my app, this is my app.js var formApp = angular.module('formApp', [ 'ngRoute', 'ui.bootstrap', 'pascalprecht.translate' ]).config(function($tra

Solution 1:

In your controller, you need to add $translate as a dependency.

formApp.controller('myCtrl', function ($scope, $translate) {
 //code
});

So for example in the html, you must have a ng-controller at some point before those elements, thats the controller that needs the dependency injected as a parameter.

<divng-controller="myCtrl">
  ...
  <h2translate>HEADLINE</h2><ptranslate>INTRO_TEXT</p>
  ...
</div>

Also in the config block you need to set the prefered language:

$translateProvider.preferredLanguage('en');

Post a Comment for "Angular-translate Unknown Provider"