我正在尝试计算ng-bind-html中的表达式,但它不起作用。如果有人知道解决此问题的方法,请提供帮助。
下面的代码没有显示任何内容。
<h5 ng-bind-html="{{feedType ==='popularProducts' ? displayedProduct.title : displayedProduct.name}}"></h5>发布于 2020-01-01 18:39:11
ngBindHtml指令期望属性值作为表达式,因此不需要{{}}插值。只需删除这些大括号,这样就可以将表达式直接传递给指令。
工作语法:
<h5 ng-bind-html="feedType === 'popularProducts' ? displayedProduct.title : displayedProduct.name"></h5>适用的AngularJS docs
https://stackoverflow.com/questions/59550926
复制相似问题