Search code examples
javascriptangularjsangular-translate

Angular Translation in JavaScript File


I have followed the Angular translation example and html page translation is working by calling with filter, say {{'TITLE' | xlat}}

I want to use the translation in JavaScript file. I tried calling $scope.xlat(), $xlat() or xlat().

How to refer and do the translation in JS file?


Solution

  • It should be probably:

    $filter('xlat')('TITLE')
    

    Also, remember that '$filter' must be injected.