I am using angular-translate to display different languages in my application, but I get an error when I try to refresh the translation data after a successful login or via other web service calls.
Note: I successfully invoke $translateProvider.useLoader
in my "app.config" to set the default translation data. But I need to reset that data dynamically in the app after any web service call as the language data varies by logged-in user's organization (or may change at any time).
This is the code I tried which gives me a $translateProvider
unreferenced error:
var ctrl = angular.module('app.ctrls', ['pascalprecht.translate']);
ctrl.controller('LoginCtrl', ['$translate'
,'$translateProvider' // << error!
, function( $translate
, $translateProvider ) {
...
// call web service to refresh "translations" in $translateProvider
}]);
FYI, the application is a mobile app using the Ionic framework which is based on angularjs.
Providers can only be used during the configuration phase. Once the application runs, only services (created by the providers) are available.
But the $translate
service has a refresh()
method.