[英]Issues Applying css styles conditionally to a twitter-bootstrap table
我有一張包含產品列表的表。 在表格下方,我有一個文本字段,在其中輸入了條形碼,如果找到條形碼,則應突出顯示表格中的匹配行。 我已經閱讀了許多類似的場景,據我所知,我正在盡我所能。 我可以在Google開發人員控制台中看到我輸入的條形碼與表中當前唯一的產品相匹配,但是由於某種原因CSS沒有得到應用...知道我在這里做錯了什么嗎?關於修復它?
我的CSS:
.found {
background-color: green;
}
我的html表格和輸入字段:
<table class="table table-striped">
<thead>
<tr>
<th>Description</th>
<th>Price</th>
<th>Qty</th>
<th>Barcode</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of ticket.items" [class.found]="item.Barcode === spotCheckBarcode">
<td>{{item?.ProductDetail_Name}}</td>
<td>{{item?.Amount}}</td>
<td>{{item?.Qty}}</td>
<td>{{item?.Barcode}}</td>
</tr>
</tbody>
</table>
<form role="form" [formGroup]="spotCheckForm" (ngSubmit)="spotCheck(spotCheckForm.value.itemBarcode)">
<input class="form-control" type="tel" placeholder="Enter item barcode" [formControl]="spotCheckForm.controls['itemBarcode']">
<button class="btn btn-block" [disabled]="!spotCheckForm.controls['itemBarcode'].valid && busy"><span class="glyphicon glyphicon-search"></span> Search</button>
</form>
//我的ts組件函數,用於設置spotCheckBarcode
spotCheck(itemBarcode: number) {
let found: boolean = false;
for (var i: number = 0; i < this.ticket.items.length; i++) {
if (itemBarcode === this.ticket.items[i].Barcode) {
console.log('found!');
found = true;
this.spotCheckBarcode = itemBarcode;
}
}
if (found == false) {
console.log(`found in if statement: ${found}`);
this.showError("Item not found on ticket");
}
}
您的課程不適用於td。 您需要在此處使用表的CSS更加具體。
.found td { background-color: green; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.