I am trying to apply conditional filltering in my html using an Angular filter:
Filter in JS file:
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 Code:
<td>
<span ng-bind-html="{{statement.IsTrue | conditionFormat}}"></span>
</td>
The output of this is literally:
<span style="color:#008000; font-weight:bold;">The statement is true</span>
Is there a way to encode the return string in HTML? or perhaps another way of accomplishing this?
thanks in advance.