下面代码的输出应该是绿色的,对于 h2 标签,但它是正常的黑色,为什么?
The output of the below code should be in green color, for h2 tag but it in normal black , Why?
Angular 代码绿色未出现
app.component.css
.text-success{color:green}
app.component.html
<h2 [ngClass]='borde'>Hello World</h2>
app.component.ts
showColor:true
public borde={text-success:this.showColor}
您没有将 showColor
设置为 true。您将类型设置为 true,但没有设置值。如果将其更改为 showColor = true
,它应该可以正常工作。
Angular 代码绿色未出现
app.component.css
.text-success{color:green}
app.component.html
<h2 [ngClass]='borde'>Hello World</h2>
app.component.ts
showColor:true
public borde={text-success:this.showColor}
您没有将 showColor
设置为 true。您将类型设置为 true,但没有设置值。如果将其更改为 showColor = true
,它应该可以正常工作。