Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

decode a html in typeScript angular 2

I'm getting from the back-end an encode html but I can't decode it.

I tried with decodeURIComponent and decodeURI.

I got from server='
"<table style="background-color: white;">
    <tbody>
        <tr>
            <td>
                    <div id="voucher">
                        <table>
                            <tr>
                                <td colspan="1" class="normal-left">ID:</td>
                                <td colspan="3" class="normal-left">ce203c7c804c4f258947adf3d63b2d7d</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </td>
        </tr>
    </tbody>
</table>"
' 

// This is my HTML

<ion-content padding>
<ion-list>
  <ion-item>
    <span [innerHtml]="aux"></span>
  </ion-item>
  </ion-list>
</ion-content>

And this is the result

I used to decode in Jquery with document.getElementById("aux").innerHTML = $('').html(voucher).text();

But I don't know if Angular 2 has something similar.

Thanks

like image 301
Javier Perez Avatar asked Nov 29 '16 00:11

Javier Perez


1 Answers

Maybe you need some directives, such as [innerHtml]. Please to use try this example:

 <div [innerHTML]="var_string"></div>

and the var_string = "<strong>example</strong>";

like image 186
Celso Agra Avatar answered Oct 17 '22 16:10

Celso Agra