我试图使用角度滤波器在我的HTML应用条件filltering:AngularJS - 条件格式使用过滤器
angular.module('myFilter', []).filter('conditionFormat', function() {
return function (input) {
return (input
? '<span style="color:#008000; font-weight:bold;">The statement is true</span>'
: '<span style="color:#008000; font-weight:bold;">The statement is <span style="color: #FF0000;">NOT</span> true</span>');
};
});
HTML代码:
<td>
<span ng-bind-html="{{statement.IsTrue | conditionFormat}}"></span>
</td>
在JS文件
过滤器
字面上的输出是:
<span style="color:#008000; font-weight:bold;">The statement is true</span>
有没有办法在HTML中编码返回字符串?或者完成这个的另一种方式?
在此先感谢。