1
私は疑問があり、解決方法はわかりません。サーバーからデータを取り出してテーブルに表示します。これらのフィールドの1つは、 'OK'、 'ERROR'または 'CANCEL'のような値を持つ文字列です。値に応じていくつかのブートストラップクラスを割り当てることは可能ですか?たとえば、「OK」の場合はbg-succes、「CANCEL」の場合はbg-dangerです。角度2 - 文字列の値に依存するブートストラップクラスを設定する
例:ところで
<table class="table table-hover">
<thead class="thead-inverse">
<tr>
<th class="text-center"><strong>Date 1/ Date 2</strong></th>
<th class="text-center"><strong>Status</strong></th>
<th class="text-center"><strong>Date 3</strong></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of items">
<td class="text-center">
<tr class="text-center"> {{item.Date1}} </tr>
<tr class="text-center"> {{item.Date2}} </tr>
</td>
<td class="text-center">
<tr>Status</tr>
<tr class="bg-success"> {{item.Status}}</tr>//Want to assign here the class
</td>
<td class="text-center"> {{item.Date3}} </td>
</tr>
</tbody>
</table>
ありがとう!
ように注意してくださいしかし、角度は大文字と小文字が区別されます。あなたのキーはOK、ERROR、CANCEL、ok、error、cancelではありません。 – trichetriche
それは動作します!しかし、配列の最初の要素だけです。/ – Aw3same
@trichetriche角についてではなく、ここでは辞書キーで大文字と小文字が区別されます:pリストを更新しましたが、頭がおかしくなりました.. –