My below given response comes as encoded format , i am decoding it using a filter and displaying value in my html . But I need to display them as html in my view. So trustAsHtml has been used. but the problem here is when I use trustAsHtml my decoding doesn't occur.it shows exception unexpected token.
$scope.res= "data": [
{
"jd": "<p>this jd1</p>"
},
{
"jd": "<li>this jd2</li>"
},
{
"jd": "<ul>this jd3</ul>"
},
{
"jd": "<p>this jd4</p>"
}
]
}
JS:
$scope.trustAsHtml = $sce.trustAsHtml;
Filter:
app.filter('decodeFilter', function() {
return function(input) {
return decodeURIComponent(unescape(input));
};
});
Html:
<div ng-repeat="item in res">
<div ng-bind-html ="trustAsHtml(item.jd | decodeFilter)">
</div>