我想在角度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;
}
一個愚蠢的錯誤我。感謝您指出。 –