我最近開始學習Angular2。在Angular 2的數值範圍內使用ngSwitch
我想知道是否有使用ngSwitch或ngIf angular2
指令的特定數值範圍內的可能性?
說我想根據範圍更新一些文本的顏色。
<25 = Mark the text in red
>25 && <75 = Mark the text in orange
>75 = Mark the text in green
如何使用Angular2 ngIf/ngSwitch指令實現相同。
有沒有辦法寫這樣的東西?
<div [ngIf]="item.status < 25">
<h2 class="text-red">{{item.status}}</h2>
</div>
<div [ngIf]="item.status > 25 && item.status < 75">
<h2 class="headline text-orange">{{item.status}}</h2>
</div>
<div [ngIf]="item.status > 75">
<h2 class="headline text-green">{{item.status}}</h2>
</div>
或者任何與使用ngSwitch,ngSwitchWhen語句有關的事情。