I have a html data coming from a server as a string that i wanted to display on the client side,So using a below filter resolve my problem but i also see error in console that i pasted in question.
How can i correct filter
implementation ?
Data varies and changed its not just html every time it renders it could be plain string as well.
filter.js
angular.module('App').filter('trusted', ['$sce', function ($sce) {
return function(url) {
return $sce.trustAsResourceUrl(url);
};
}]);
main.html
<tr ng-repeat="item in showMessages | filter:searchStr">
<td>{{item.filename}}</td>
<td class="serverResults" ng-bind-html="item.value | highlight:searchStr| trusted">{{item.value}}</td>
</tr>
Error
Error: [$sce:itype] Attempted to trust a non-string value in a content requiring a string: Context: resourceUrl