相关疑难解决方法(0)

角度材质2.单击时将主题从亮到暗切换

所以我有一个Angular 2 Material应用程序.而我想做的只是通过点击简单来切换/切换主题从黑暗到光明button.

我该怎么做 ?

typescript material-design angular-material2 angular

5
推荐指数
1
解决办法
6496
查看次数

How to apply Angular Material theme to non-material components?

I am using Angular Material 2 themes for my Angular 4 app. I have the following themes created in my theme.scss

@import '~@angular/material/theming';
@include mat-core();

$primary-color: mat-palette($mat-grey);
$accent-color: mat-palette($mat-blue, 500, 900, A100);
$warning-color: mat-palette($mat-red);

$dark-theme: mat-dark-theme($primary-color, $accent-color, $warning-color);
$light-theme: mat-light-theme($primary-color, $accent-color, $warning-color);
Run Code Online (Sandbox Code Playgroud)

And in my style.scss, I have the following

@import 'theme.scss';

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

.light-theme {
    @include angular-material-theme($light-theme);
}
Run Code Online (Sandbox Code Playgroud)

In my HTML I have hardcoded the dark theme (eventually I want to give the user an option …

html css angular-material2 angular

4
推荐指数
1
解决办法
2759
查看次数