【问题标题】:How to change background by changing theme?如何通过改变主题来改变背景?
【发布时间】:2019-06-24 15:13:45
【问题描述】:

我在我的 css 类中设置了一个背景图像作为封面,现在我想删除它并应用背景颜色..

我尝试制作一个功能来改变主题,例如从浅色到深色,它的工作,但我不知道如何取消设置背景主题和使用背景颜色..

我需要使用 ngif 吗?

我的背景在这里:

<router-outlet class="cover-background">

这在我的 app.ts 上

     constructor(public overlayContainer: OverlayContainer){}

      @HostBinding('class') componentCssClass;

      onSetTheme(theme) {
        this.overlayContainer.getContainerElement().classList.add(theme);
        this.componentCssClass = theme;
      }

这在我的 theme.scss 中

    .dark-theme {
  @include angular-material-theme($dark);
}

    .light-theme {
  @include angular-material-theme($theme);
}

【问题讨论】:

    标签: angular angular-material


    【解决方案1】:

    您可以使用 ngClass 指令。

    【讨论】:

      猜你喜欢
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 2020-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-06
      • 1970-01-01
      相关资源
      最近更新 更多