簡體   English   中英

如何使用angular2中的原始進度條以不同的顏色顯示行的進度條

[英]How to show progress bar in different colors for the rows using prime ng progress bar in angular2

進度條

我有數據列表,正在顯示進度條,但我需要這些進度條具有不同的顏色。 我也嘗試了ng-class,但是沒有用。

HTML:

<td><p-progressBar width="100" [value]="statusDisplay.progressValue" [ngClass]="{'progressBar-green': statusDisplay.progressValue > 50}"></p-progressBar></td>

當我查看p-progressBar組件的代碼時,似乎可以傳遞styleClass屬性綁定將自定義類綁定到p-progressBar

<td>
  <p-progressBar width="100" [value]="statusDisplay.progressValue" 
    [styleClass]="getStyleClass(statusDisplay)"> 
  </p-progressBar>
</td>

// you can have your own logic for class.
getStyleClass (statusDisplay) {
    return statusDisplay.progressValue > 50 ? 'progressBar-green': ''
}

要么

其他方法將使用style屬性,如文檔中所示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM