【发布时间】:2018-07-17 16:40:46
【问题描述】:
我有一个 Angular 6 应用程序,我正在尝试将另一个 CSS 类应用到 app.component.html 文件中的一个应用程序组件。基本上,我想根据条件更改我的应用程序页脚的颜色,而所有其他情况都不显示页脚。所以,我的代码如下所示:
app.component.html
<router-outlet></router-outlet>
<my-footer [ngClass]="{ 'my-class' : true }"></my-footer>
我的页脚.css
:host {
background-color: black;
color: white;
}
.my-class {
background-color: red;
}
是否可以以这种方式使用[ngClass],我将条件应用于自身的组件中存在该类?我发现如果我将.my-class 放在app.component.css 文件中,那么它会按预期工作。但是,我想将我的样式放在它们所属的组件中。
谢谢!
【问题讨论】:
标签: javascript angular angular6