【问题标题】:NgStyle setting two properties AngularNgStyle 设置两个属性 Angular
【发布时间】:2020-05-27 23:52:29
【问题描述】:

我正在尝试根据条件设置两个属性。 我有这个代码:

<tr [ngStyle]="user.current ? {'background-color' : '#002147', 'color': '#fff' } 
: {'background-color': 'transparent', 'color': black}" *ngFor="let user of users; index as i">
...

我的问题是它只设置了第一个属性(背景颜色),文本颜色没有任何反应。 你能帮我么?非常感谢!祝你有美好的一天!

【问题讨论】:

  • 您可能只需要在black 周围加上引号。否则,它应该可以工作,正如您在 this stackblitz 中看到的那样。

标签: angular properties ng-style


【解决方案1】:

您应该检查并尝试其他事情,您的代码看起来正确。

  • 使用 !important 注释检查您的“tr”元素上是否已经设置了颜色
  • 尝试切换颜色和背景颜色,看看会发生什么
  • 您忘记了“颜色:黑色”属性的单引号

希望对你有帮助

【讨论】:

  • 谢谢!我的问题是css,tr上已经有颜色了。对不起我的菜鸟问题
猜你喜欢
  • 2017-07-08
  • 1970-01-01
  • 2021-09-13
  • 2015-12-08
  • 2019-05-28
  • 2017-11-17
  • 2012-06-06
  • 1970-01-01
  • 2012-06-03
相关资源
最近更新 更多