0

Is it possible to render the output from a ternary operator as html?

{{ boolA ? 'Some text' : '<i class=\"fa fa-check\"></i>' }}

Also tried to modify a inline if/else directive from a previous question but can't get this to work either.

.filter('iif', ['$sce', function ($sce) {
    return function (input, trueValue, falseValue) {
        return $sce.trustAs('html', input ? trueValue : falseValue);
    }
}])
Community
  • 1
  • 1
stibay
  • 1,200
  • 6
  • 23
  • 44

1 Answers1

4

Yes, Use ng-bind-html like this :

<span ng-bind-html=" your_condition ? 'html_if_true' : 'html_if_false' "></span>

Replace values according to your requirements.

Mihir
  • 306
  • 3
  • 18