2
A
回答
4
在你menu
:
app.component.html:
<div [class.dark-theme]="isDarkTheme">
<!--Your application content here-->
<md-menu #more="mdMenu">
<!--Your content here-->
<button md-menu-item (click)="changeTheme()">
Change Theme
</button>
</md-menu>
</div>
app.component.ts:
// import statements here
import {Component} from '@angular/core';
export class AppComponent {
// Initialize isDarkTheme to false
isDarkTheme: boolean = false;
// Your code here
changeTheme(): void {
if (this.isDarkTheme) {
this.isDarkTheme = false;
} else {
this.isDarkTheme = true;
}
}
}
theme.scss:
@import '[email protected]/material/core/theming/_all-theme';
@include mat-core();
.dark-theme {
// Dark theme
$app-dark-primary: mat-palette($mat-pink, 700);
$app-dark-accent: mat-palette($mat-blue-grey);
$app-dark-theme: mat-dark-theme($app-dark-primary, $app-dark-accent);
@include angular-material-theme($app-dark-theme);
}
相關問題
- 1. 角材2找不到核心主題
- 2. 將角質材質2主題設置爲黑色主題
- 3. Ag-grid角材料主題
- 4. 材質漣漪效應:黑暗主題與燈光主題
- 5. 角2 - 點擊
- 6. 角2材料
- 7. 使用角材2創建超過3種顏色的主題
- 8. 使用webpack加載主題材質2的角度
- 9. 角材料 - 無法解析 '@角/材料/主題化'
- 10. 材料的UI:從主題
- 11. 禁用角材料的主題風格
- 12. 角度材質2對話框顯得更暗
- 13. 角材料2,如何主題選擇下拉
- 14. 角質材料2主題在生產中不起作用
- 15. 角度材質 - $ mdSideNav - 背景點擊
- 16. 什麼是材料設計黑暗的主題顏色?
- 17. 角材2標籤
- 18. Android攝像頭2輕擊焦點
- 19. 角2 @Output用(點擊)
- 20. 角2:檢查DIV點擊
- 21. 如何點擊角2
- 22. UITableView黑暗主題
- 23. 角材料2:未找到錯誤
- 24. 使用更亮和更暗的選項的角度材質2墊調色板()
- 25. iOS UIAlertController黑暗的主題
- 26. RN的黑暗android主題?
- 27. 角度材質菜單觸發移動設備中的點擊事件2次
- 28. UIPageControl點擊「輕掃」?
- 29. 量角器 - 無法點擊角度材料標籤
- 30. jhipster 4角材2,聊天
我應該另加'sometheme.scss'到我的角cli.json文件? –
是的,你應該添加它。 – Edric