Reputation: 3441
Is the class attribute useful in angular 2 for a customized component? For example:
<app-my-first-component class='darkBackground'></app-my-first-component>
It looks like the class does not affect the component.
Upvotes: 2
Views: 93
Reputation: 657406
You can address the class by adding a style to app-my-first-component
like
@Component({
...,
styles: [`
:host(.darkBackground) {
color: white;
background-color: darkgrey;
}`]
})
Upvotes: 1
Reputation: 157
Yes, you can use class attribute. And, there is another way to do the same, using host attribute.
@Component({
selector: 'app-my-first-component',
host: {'class':'darkBackground'}
})
Upvotes: 1