【发布时间】:2020-09-07 14:41:25
【问题描述】:
我有字段总计数,我需要防止总计数显示在 component.html 上
如果你能告诉我怎么做,我已经做了但不工作?
我在标题列和正文数据上动态显示数据,角度为 7
我尝试使用下面的过滤功能但不起作用
this._displayreport.GetReportDetailsPaging(this.searchData).subscribe((data: any[]) => {
this.reportdetailslist = data;
this.headerCols = Object.keys(data[0]);
this.contentBody=data.filter(item =>item != data[0].totalCount);
});
}
}
<thead>
<tr>
<th >
<ng-container *ngIf="coln != 'totalCount'">
{{coln}}
</ng-container>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let rep of contentBody">
<td *ngFor="let coln of headerCols">
<span>
{{rep[coln]}}
</span>
</td>
</tr>
<tbody>
数据对象将以下数据表示为任意[]
companyName: "Innovasic, Inc."
done: "0"
notImpacted: "0"
notificationDate: "2009-11-12"
offilneURL: "https://source.z2data.com/2019/1/13/8/55/47/351/662203977/21527_SPCN.PDF"
onlineURL: "N/A"
pending: "3"
reportDate: "2020-05-07"
revisionID: "272299243"
teamName: "MFG"
totalCount: 79
【问题讨论】:
-
您要这样做吗? this.contentBody = data.filter(item =>item.totalCount !== data[0].totalCount);
-
感谢回复我会这样做,但所有数据和记录都没有显示
-
哦,对不起,我看错了你的问题。我认为你需要过滤你的 headerCols。 this.headerCols = Object.keys(data[0]).filter(x => x !== 'totalCount');
标签: javascript angularjs typescript angular7 angular-components