Search code examples
javascriptangularjsangular-translate

Angular translate service: HTML tags in string


I have an KEY which contains a string with a HTML tag: Foo <strong>bar</strong> and I'm using the angular translate service:

$translate('KEY').then(function(text) {
    $scope.text = text;
});

As output I get Foo <strong>bar</strong>, but I want to get 'Foo bar'. Is there are way to get this with the translate service?

I already set the sanitize strategy to sanitize, but even this does not help. I know that it works with the translate directive but it doesn't fit to my use case.


Solution

  • You can use the ngBindHtml directive:

    <div ng-bind-html="text"></div>