Parse html from json

Hello Ionics, I have a JSON with HTML tags. I want parse this input HTML to text for print on my app

I’m using this filter:

.filter('htmlToPlaintext', function() {
    return function(text) {
        return String(text).replace(/<[^>]+>/gm, '');

and this my markup:

<p>{{noticia.texto | htmlToPlaintext}}</p>

but I have the result: “undefined”

anyone help me please?

Thanks in advance!

I wrote a post about Filters with AngularJS and HTML parsing, maybe this can solve your problem: Using AngularJS Filters for HTML Parsing

Hello @saimon! Thanks for your answer, nice tutorial, it works perfectly!

I have a more question:

My JSON request return:

<u><strong><a href=\"\">Tecsidel</a></strong></u>

and your filter return:">Tecsidel

How I can modify your code for only show Tecsidel without lost the link?

Thanks so much!

As you don’t need to replace anything, just remove the regex and replacement and your HTML should be displayed fine (works for me)!