【发布时间】:2023-03-12 02:59:01
【问题描述】:
我正在尝试在 Angular 2 中使用样式绑定,但不知何故我错过了导致它无法工作的部分。目的是让默认文本变为灰色,当用户点击它(代码尚未制作)时,它会变为 deeppink。但是在测试 style 属性时,它似乎不起作用。
import { Component } from "@angular/core"
@Component({
selector: "like",
template: `
<i class="glyphicon glyphicon-heart" [style.color]="color ? 'grey' : 'deeppink'" style="font-size: 100px;"></i>
`
})
export class LikeComponent {
count: number = 10;
color: true;
}
【问题讨论】: