Angular 2 use Shadow DOM, that is part of the Web Components standard and enables DOM tree and style encapsulation.
Angular View Encapsulation
So if you want to style something in my-component you should write your class's in my-component class.
import { Component, OnInit } from '@angular/core';
@Component({
teamplte: '<h1 class="myClass">i am my-component</h1>',
styles: [`
.myClass {
someProp: value;
}
`]
})
export class ConatinerComponent implements OnInit {
constructor() { }
ngOnInit() { }
}
but if you want to style outside you must to write your styles and classes in container component!
import { Component, OnInit } from '@angular/core';
@Component({
teamplte: '<my-component class="myClass"></my-component>',
styles: [`
.myClass {
someProp: value;
}
`]
})
export class MyComponentComponent implements OnInit {
constructor() { }
ngOnInit() { }
}