This is due to the specifics of innerHtml and angular 2 encapsulation.
1 Method
Connect the css file via <link rel="stylesheet" href="путь к файлу"></link> and specify the necessary classes in it that are in innerHtml. That is, we do as in any project.
2 Method
Set styles with :host >>> .class .
In the example below there is a certain block <div [innerHTML]="someHtml"></div> into which some HTML will be inserted
<p class="styleP1">Hello</p> <p class="styleP2">Hello</p>
with classes .styleP1 , .styleP2 .
The first <p class="styleP1">Hello</p> style does not apply, because it is not set via: host, the second <p class="styleP2">Hello</p> will turn red.
@Component({ selector: 'my-app', template: ` <div> <div [innerHTML]="someHtml"></div> </div> `, styles: [ `:host >>> .styleP2 { color: red; } .styleP1, .styleP2 { color: red; }` ], }) export class App { constructor() { this.someHtml = `<p class="styleP1">Hello</p> <p class="styleP2">Hello</p>`; } }