A
A
Abra Kadabra2018-05-12 15:47:41
Angular
Abra Kadabra, 2018-05-12 15:47:41

Why does :host work inside component styles, but its (component) selector doesn't?

Angular 6.0
I'm creating internal styles for a component, but I can't use its (component) selector inside a .scss file.
Moreover, this selector is not selected, both inside the component styles and global styles.
Component declaration:

@Component({
    selector: 'dashboard',
    templateUrl: 'dashboard.html',
    styleUrls: ['dashboard.scss'],
})

Not working style:
.dashboard {
    color: red;
}

Working Style:
:host {
    color: red;
}

Is it possible to use the `dashboard` selector in `dashboard.scss`.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-05-12
@Jmaster

Is it possible to use the `dashboard` selector in `dashboard.scss`.

It is forbidden.
Read the documentation , it says so:
Если отключить инкапсуляцию стилей компонента, то заработает так, как вам хочется. Правда, я бы этого делать не стал.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question