更新时间:2022-05-15 02:55:31
你可以使用 ng-class
<span ng-class="{red: past == 'yes', black: past == 'no'}">{{somedue.date}}</span>
将应用红色或黑色类的位置.您可以通过 CSS 设置样式,使颜色变为红色/黑色.
where the classes red or black will be applied. You can style those via CSS to make the color red / black.
示例:http://jsfiddle.net/TheSharpieOne/NHS73/
您的示例中的数据结构很奇怪,我的示例中已对其进行了修改以展示 ng-class
.
Your data structure was odd in your example, it has been modified in mine to showcase ng-class
.
另外:您可以使用 true
/false
而不需要对 'yes'
/'no 进行字符串比较'
.
Also: You could use true
/ false
and not need to do a string comparison to 'yes'
/'no'
.