我有一個顯示物件屬性的表。我想知道是否有一種簡單的方法可以更改單元格顯示的文本而不是該值設定的真/假。
例子。我有一列通知物件是打開(真)還是關閉(假)。我想顯示打開/關閉,而不是顯示真/假。
該列是“狀態”。它是一個布爾屬性。是否可以僅在 html 上進行此操作,還是應該更改組件檔案中的某些內容?(有棱有角)
<table class="table table-dark table-condensed table-bordered table-striped table-hover">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">State</th>
<th scope="col">Resolved By</th>
<th scope="col">Hours to resolve</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let bug of bugs">
<th scope = "row">{{bug.id}}
<td>{{bug.name}}</td>
<td>{{bug.description}}</td>
<td>{{bug.state}}</td>
<td>{{bug.resolvedBy}}</td>
<td>{{bug.hoursToResolve}}</td>
</tr>
</tbody>
</table>
</div>
謝謝!
uj5u.com熱心網友回復:
三元運算子的一個很好的例子:
<table class="table table-dark table-condensed table-bordered table-striped table-hover">
<thead>
<tr>
<th scope="col">Id</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">State</th>
<th scope="col">Resolved By</th>
<th scope="col">Hours to resolve</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let bug of bugs">
<th scope = "row">{{bug.id}}
<td>{{bug.name}}</td>
<td>{{bug.description}}</td>
<td>{{bug.state ? 'True Value Here' : 'False Value Here'}}</td>
<td>{{bug.resolvedBy}}</td>
<td>{{bug.hoursToResolve}}</td>
</tr>
</tbody>
</table>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/353257.html
上一篇:導航欄不在中心
