In jQuery, if you have a string with HTML in it you can process the HTML in it and replace special characters like '&' with '&'
var myString = 'Jack & Jill';
var filtered = $('</div>').html(myString).text();
console.log(filtered); // outputs 'Jack & Jill'
I am writing a filter which would process HTML, but I'm depending on jQuery here, is there an AngularJS way to do it?
Here is my Filter code:
myApp.filter('filterHtmlChars', function() {
return function(html) {
return $('<div/>').html(html).text(); // how could I use AngularJS here?
};
});
PS: I already know about ng-bind-html, what I'm trying to do is filter.