Answer the question
In order to leave comments, you need to log in
Angular2 - how not to lose the link of styles when connecting a component?
Essence of the question:
<div style="display: flex">
<app-component><!-- Внутри флекс элементы --></app-component>
</div>
<app-component>
, and not what is inside. Answer the question
In order to leave comments, you need to log in
<div>
<app-component><!-- Внутри флекс элементы --></app-component>
</div>
...
@Component({
selector: 'app-component',
templateUrl: '...',
host: {
'class': 'app-flex-style'
}
})
export class AppComponent {
....
}
There is one more option that can be useful in some cases (for example, when working with tables).
Add an attribute to the component selector:
...
@Component({
selector: 'app-component,[appComponent]',
templateUrl: '...',
})
export class AppComponent {
....
}
<div appComponent style="display: flex">
<!-- Внутри флекс элементы -->
</div>
<div>
<app-component style="display: flex"><!-- Внутри флекс элементы --></app-component>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question