Reputation: 115
I'm trying to evaluate an expression in ng-bind-html but it's not working. If anyone knows workaround for this, please help.
The code below is showing nothing.
<h5 ng-bind-html="{{feedType ==='popularProducts' ? displayedProduct.title : displayedProduct.name}}"></h5>
Upvotes: 2
Views: 564
Reputation: 156
The ngBindHtml
directive expects the attribute value as an expression so there is no need for the {{}}
interpolation. Simply remove those braces so that you’re passing your expression directly to the directive.
Working Syntax:
<h5 ng-bind-html="feedType === 'popularProducts' ? displayedProduct.title : displayedProduct.name"></h5>
Applicable AngularJS docs
Upvotes: 3