Escape HTML angular filter

By: Ryan Wong at

This filter is very useful for you to escape all html from a string.

1
2
3
4
5
6
7
function htmlToPlainText() {
return function(text){
return String(text).replace(/<[^>]+>/gm, '');
};
}
angular.module('customFilter', [])
.filter('htmltoplaintext', htmlToPlainText)

Hope this helps you out.