Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
create a filter that will format the string.
angular.module('app')
.filter('stripHTML',function(){
return function(str){
return str.replace(/<\/?[^>]+>/gi, '');
}
})
I would recommend doing this not in filters (although you can, of course, there), but in the service where you get the data (or, again, use the filter there).
The best way to remove tags is not with a regular expression, as suggested by rakro , but using the DOM:
function stripTags(html)
{
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question