How to get the result of a JSON where the result is HTML and in the Ionic View render the HTML?

Asked

Viewed 125 times

0

I have a JSON where the contents of some fields are HTML, I would like to present the HTML in the Ionic View already rendered.

This is the JSON:

[{"data":"2018-09-05","categoria":"1","desafio":"
\r\n
Burp 20x1<\/li>\r\n
Teste 30x4<\/li>\r\n
Variação 50x10<\/li>\r\n<\/ul>\r\n
Competição<\/strong><\/p>\r\n

\r\n
Luta livre<\/li>\r\n
Burp<\/li>\r\n<\/ul>","titulo":"Desafio do Dia"}]

The "challenge" field is in HTML, how to render HTML in View?

<ion-header>
  <ion-navbar color="dark">
    <ion-title text-center>Workout do Dia</ion-title>
  </ion-navbar>
</ion-header>
<ion-content padding>
  <div class="container">
    <ul *ngFor="let workout of workoutdetalhes">
      <li><span></span>
        <div>
          <div class="title">{{workout.titulo}}</div>
          <div class="info">{{workout.desafio}}</div>          
        </div> 
      </li>    
    </ul>
  </div>
</ion-content>

1 answer

1


<div [innerHTML]="workout"></div>
  • Thanks @Hitmacreed wasn’t sure how to put it, it worked: <ion-card-content [innerHTML]="Workout.desafio"> {{Workout.desafio}} </ion-card-content> Thanks.

  • 2

    @Hitmacreed, it is recommended that you detail a little more your answer, explaining in general what you do.

  • 1

    It would be interesting if you detailed your answer a little, explaining why @Ramos should use this part in their code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.