css - 如何在 Angular 的 NgStyle 中应用默认值?
问题描述
我用它来改变元素的背景。
[style.background-color]="condition ? 'red' : 'green'"
但是因为我要使用主题 - 我不知道当前的default
背景颜色是什么..
我应该如何重写以上内容以支持任意主题样式?
解决方案
在之前设置默认背景[style.background-color]="condition ? 'red' : 'green'"
所以,代码将是
style="background-color:blue" [style.background-color]="condition ? 'red' : 'green'"
这里蓝色是默认的
推荐阅读
- r - R:从混合数字和字母的字符串中提取最大数字
- javascript - 如何在不使用 nativeElement 的情况下自动聚焦 Angular 10 中的表单控件
- laravel - NGINX 和 Laravel - 带有特殊字符的 json 发布请求
- python - AttributeError: 'WebElement' object has no attribute 'get_text' 使用 Selenium Python 提取开始和结束标记之间的文本时出错
- javascript - 如何从 react 和 firebase 为每个用户创建用户页面
- azure - 如何在 Azure DevOps Pipeline (Salesforce) 中增加标签
- asp.net - 为什么插入过程在 ASP.NET 中不起作用
- python - Python:如何将列数据 csv 转换为行数据
- linux - 如何测试/验证 vmalloc 保护页面在 Linux 中是否正常工作
- elasticsearch - 数组中的elasticsearch匹配查询