Growler Growler - 3 months ago 38
AngularJS Question

Angular ternary with html

How can I include html in a ternary operator?

{{ (q.result === 1) ? "<i class="fa fa-check" aria-hidden="true"></i>" ? "<i class="fa fa-times" aria-hidden="true"></i>" }}

If not possible, I guess the obvious alternative is to do two wrapping element blocks with
<div ng-if="result">HTML</div>
<div ng-if="!result">OTHER HTML</div>


You can acccomplish what you want with ng-class. It actually supports the ternary operator

<i class="fa" aria-hidden="true" ng-class"(q.result === 1) ? 'fa-check' : 'fa-times'"></i>