[英]AngularJS ng-bind-html not working with expression
I'm trying to evaluate an expression in ng-bind-html but it's not working.我正在尝试评估 ng-bind-html 中的表达式,但它不起作用。 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>
The ngBindHtml
directive expects the attribute value as an expression so there is no need for the {{}}
interpolation. ngBindHtml
指令期望属性值作为表达式,因此不需要{{}}
插值。 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.