Ionic2 components no style after innerHTML


Hi all. Here’s what i’m trying to do:

I have a string with html and ionic elements in my .ts file:

page_content = "<ion-card class='card-ios'><ion-card-header>Header</ion-card-header><ion-card-content>Card Content</ion-card-content></ion-card>"

then i want to inject that string in a div in the html page:



the problem is that the style of the card is not applied to the content, if i insert the code directly in the html it shows fine.

with innerHTML

inserted directly

Thanks in advance.


I would strongly suggest rethinking the design and getting all the HTML handling out of the component code. HTML belongs in templates.