Display html element from JSON object on ionic App


#1

I have been trying to embed html element from JSON object, and It is currently displaying the html as raw code instead.

Can someone please help me ?

detail.ts

this.questionsData[i].question_type.title = "<ion-input type=\"text\" placeholder=\"Short answer\"></ion-input>";

detail.html

<ion-item  *ngFor="let question of questionsData">
      {{question.title}}
      <br>
      Text : {{question.question_type.title}}
      <br>
     <div   [innerHTML]="question.question_type.title">
    </div>
</ion-item>

Isn’t it should be input box under the text : , anyone know why it’s not rendered ?

Thanks


#2

Yes, but it’s a very long story and you’re not going to like the ending, which is “you’re bettter off rethinking the design”. I suggest something along these lines and/or this.