我試圖使用角度濾波器在我的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中編碼返回字符串?或者完成這個的另一種方式?
在此先感謝。