英文:
How to switch between predefined material themes?
问题
In Angular Material, we have 4 predefined themes:
indigo-pink
pink-bluegrey
purple-green
deeppurple-amber
我想要将这四个主题都包含在应用程序中,并提供在运行时切换它们的方式。
Q: 如何在运行时切换预定义的 Material 主题?
注意 - 我不打算创建任何自定义主题,我只想使用预定义的主题。这应该很简单,但我找不到任何做这个的示例。
我正在使用 Angular v16。
英文:
In Angular Material, we have 4 predefined themes:
indigo-pink
pink-bluegrey
purple-green
deeppurple-amber
I want to include all 4 of them into them app, and provide a switch between them.
Q: How can we switch between predefined material themes at run-time?
Note - I do not intend to create any custom theme, I just want to use the predefined ones. It's supposed to be very easy, but I cannot find a single example of doing that.
I'm using Angular v16
答案1
得分: 1
以下是翻译好的内容:
你问题的确切答案在 Angular Material 文档中。
他们也在文档网站上使用切换器来切换主题。
你可以查看文档网站的源代码,肯定会找到切换器的逻辑!再见
英文:
The exact answer for your question is on the angular material docs itself.
They too use a switcher to switch between themes on the documentation website.
You can just dig up through the documentation website source code, you will surely find the switcher logic somewhere for sure ! Adios
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论