我想在角度2中使用样式绑定,但不知何故我错过了导致它不工作的部分。目的是让默认文本变灰,当用户点击它(代码还没有制作)时,它会变为deeppink。但是,在测试样式属性时,它似乎不起作用。angular2 [style.color]不能正常工作
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;
}
一个愚蠢的错误我。感谢您指出。 –