嗨,我正在使用 Angular,我想在 ng-bind-html-unsafe 中执行一个表达式,以便它可以在两个文本之间进行选择以显示。这是表达式的正确语法吗?
<div ng-bind-html-unsafe="{{ 0 && text || text2}}"></div>
这是一个jsfiddle这表明了我的问题。
最佳答案
尝试不使用大括号:
<div ng-bind-html-unsafe=" 0 && text || text2"></div>
输出:
HELLO THERE2
对于
<div ng-bind-html-unsafe=" 1 && text || text2"></div>
输出
HELLO THERE
顺便说一句,ng-bind-html-unsafe
已从新版本中删除。将来可能会导致错误
关于angularjs - Angular ng-bind-html-不安全表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19145785/