togglePageCSS(toggle: 'add' | 'remove') {
if (toggle === 'add') {
this.renderer.addClass(
document.querySelector('.app-header'),
'app-header--fixed'
);
} else if (toggle === 'remove') {
this.renderer.removeClass(
document.querySelector('.app-header'),
'app-header--fixed'
);
}
}
我需要从组件的头添加一个类。我使用渲染器来做到这一点。问题是我不知道应该将应用程序标头固定在哪个css文件中。
答案 0 :(得分:0)
您的应用程序在styles.css/scss
下有一个src
。应该在那里。
可以通过在其他地方和css/scss
处创建新的@import "<path to your file>"
文件来实现另一种方法,因此该文件在您应用的根目录中可见。
因此,您要与Renderer 2一起使用的所有类都应该是全局的。