To define your component using its selector and host
, you can follow this example:
combine.scss
:host(app-one) {
color: 'green';
}
:host(app-two) {
color: 'blue';
}
components
@Component({
selector: 'app-one',
template: `<h1>Hello</h1>`,
styleUrls: ['./combine.scss']
})
export class ChildTwo {}
@Component({
selector: 'app-two',
template: `<h1>World</h1>`,
styleUrls: ['./combine.scss']
})
export class ChildOne {}
parent component
<app-one></app-one>
<app-two></app-two>
The project structure will look something like this:
> child-one.component.ts
> child-two.component.ts
> parent-component.ts
> combine.scss
Remember, this is just a sample structure. If your files are in separate folders, ensure to specify the correct path in the styleUrls
array.
Check out the demo here