Reputation: 8959
I'm trying to get the text defined in our translations.js file in order to pass it to an angular-bootstrap alert as its text. I've injected the $translate service into the controller and am using the $translate service like so:
$translate('TXT_ALERT_MSG').then(function (translation) {
$log.debug( translation );
});
but it breakes angular and states the following error message:
TypeError: object is not a function
This is thrown on the very first line of the code above. I wrapped it in a promise to make sure i only print the value upon successfully retrieving the translation. I also tried assigning the value to a variable but this throws the same error:
function getTranslation() {
var msg = $translate('TXT_ALERT_MSG');
$log.debug(msg);
}
getTranslation();
This is most likely something simple so what is it?
Thanks
EDIT How I inject the translate module into the app:
angular.module('MainApp',['pascalprecht.translate']);
and how it's configured:
angular.module('MainApp').config(['$translateProvider', 'ConfigProvider', function ($translateProvider, ConfigProvider) {
var config = ConfigProvider.$get();
var rootUrl = config.get('ourRootUrl');
$translateProvider.translations('en', {
// all our translations e.g.
TIMED_OUT_BUTTON: 'Return to Dashboard'
$translateProvider.preferredLanguage('en');
}]);
Upvotes: 0
Views: 1315
Reputation: 1998
Try to get the translations by translate filter
$filter('translate')('TIMED_OUT_BUTTON')
Upvotes: 2