What is the right way to override child component style from host component. I tried using encapsulation: ViewEncapsulation.None
but i need to write the override stuff in style.sass file rather than host component. What should be the stackblitz
相关问题
- Angular RxJS mergeMap types
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- How to update placeholder text in ng2-smart-table?
- How to instantiate Http service in main.ts manuall
- Angular: ngc or tsc?
相关文章
- angular脚手架在ie9+下兼容问题
- angular 前端项目 build 报错 "Cannot find module 'le
- Angular Material Stepper causes mat-formfield to v
- After upgrade to Angular 9 cannot find variable in
- is there any difference between import { Observabl
- Suppress “Circular dependency detected” suppress w
- How can you get current positional information abo
- Angular material table not showing data
My "way" is using viewEncapsulation.None, important and add class to the child. the forked stackblitz's Connors
If you have control on the child component code, you can define a
customStyle
input property:and pass it from the parent component:
See this stackblitz for a demo.
A similar technique can allow to pass a specific style attribute to the child component:
from the parent component:
See this stackblitz for a demo.
Otherwise, until an alternative method is proposed by Angular, you can use the
::ng-deep
shadow-piercing descendant combinator to modify the child component styling from the parent CSS:See this stackblitz for a demo.