Search code examples
angularjsangular-translate

using angular-translate in controller gives me an object object


how do i get the text from the $translate ? i get an "[object Object]" if i do it like this:

var str = '<b>' + $translate('room') + '</b><br>';

if ($scope.ad.category == '2' || $scope.ad.category == '1') {
    str = '<b>' + $translate('flat') + '</b><br>';
} else if ($scope.ad.category == '3') {
    str = '<b>' + $translate('house') + '</b><br>';
}

i'm sure that this is quiet simple and i just don't see the problem (like always -_-)


Solution

  • Try using

    $translate.instant('key'); // JS
    

    or

    <b>{{ 'flat' | translate }}</b><br> <!-- HTML -->