我在rowstyleclass中出错:
错误:意外令牌'eq'
我正在使用primeng2。样式类格式书写不正确吗?请提出建议
HTML
<p-dataTable [value]="dealerDetails.current" [sortMode]="multiple" [rows]="10"
[responsive]="true" [editable]="false" resizableColumns="true"
reorderableColumns="true" selectionMode="single"
(onRowSelect)="onRowSelect($event)" class="ui-column-titleLeader"
[rowStyleClass]="rowStyleClass">
<div style="font-weight: 900">
<p-column field="rank" header="{{'RANK' | translate}}" styleClass="table_col_width90px">
<template let-i="rowIndex" pTemplate="body">
<div>
<img src="{{'app/resources/images/Leaderboard Icon/medal icon 1st.jpg'}}" />
<span style="position: absolute; left: 24px;bottom: 18px;font-size: 14px;font-weight: bold;font-family: fantasy;">{{i+1}}</span>
</div>
</template>
</p-column>
</p-dataTable>
更新:
将eq
更改为===
后,出现以下错误:
无法读取未定义的属性“代码”
ts代码:
this.customerService.getDealerDetailsLeaderboard
(this.selectedCustomer.id,this.globalSharedService.getJWTHeaderURLEncoded())
.subscribe(
dealerData =>{
this.dealerDetails = dealerData;
}
在我控制台的ts文件中,它显示了selectedCustomer.code
和dealerDetails.current.code
的值
附加功能
rowStyleClass(){
if(this.selectedCustomer && this.dealerDetails.current &&
this.dealerDetails.current.code === this.selectedCustomer.code){
return 'red'
};
}
但是错误再次出现未定义的“代码”