A component’s styles can be encapsulated within the component’s host element so that they don’t affect the rest of the application.
import {ViewEncapsulation} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'my-zippy',
templateUrl: 'my-zippy.component.html',
styles: [`
.zippy {
background: green;
}
`],
encapsulation: ViewEncapsulation.None
})
class ZippyComponent {
@Input() title: string;
}
References
https://angular.io/api/core/ViewEncapsulation
https://blog.thoughtram.io/angular/2015/06/29/shadow-dom-strategies-in-angular2.html