Home > database >  How to convert HTML codes in JSON file to characters in Ionic 3
How to convert HTML codes in JSON file to characters in Ionic 3

Time:02-03

I'm trying to read in some JSON files to HTML but the HTML characters are displaying as codes. I've tried using [innerHTML]="{{item.detail}}" but its not working, any help please?

Code sample:

            <ion-row *ngFor="let item of items; index as i;">
              <span >{{item.topic}}</span><br>
              <span >{{item.excerp}}</span><br>
              <ion-col >[innerHTML] = "{{item.detail}}"<br>
                
                

CodePudding user response:

innerHTML is a directive

<ion-row *ngFor="let item of items; index as i;">
              <span >{{item.topic}}</span><br>
              <span >{{item.excerp}}</span><br>
              <ion-col  [innerHTML] = "item.detail"></ion-col>
</ion-row>

or

<ion-row *ngFor="let item of items; index as i;">
              <span >{{item.topic}}</span><br>
              <span >{{item.excerp}}</span><br>
              <ion-col  innerHTML = "{{item.detail}}"></ioncol>
</ion-row>
  •  Tags:  
  • Related