我目前正在使用ngx-datatable。
我在订阅后收集数据并将其存储在dataRows中:
this.dataRows = res.data.items;然后将其传递给ngx-datatable
<ngx-datatable
class="bootstrap"
[rows]="dataRows"
[columns]="dataColumns"
[columnMode]="'force'"
[headerHeight]="50"
[selectionType]="'single'"
[selected]="selected"
(select)="recordSelected()"
[messages]="{emptyMessage: 'Data not found!', totalMessage: 'total'}"
[count]="totalItems"
>
</ngx-datatable>我的问题是如果dataRows为空,它会显示空消息,但我也会收到错误消息
core.js:1350 ERROR TypeError: Cannot convert undefined or null to object发布于 2020-02-26 19:08:29
您的sintax没有任何问题,您已经按照手册中的说明使用了它:
[messages]="{emptyMessage: 'There are no records...'}"正如@suraz建议的那样,检查其他可能的错误
发布于 2019-02-06 17:33:48
使用if条件进行检查..例如,如果( data !== null){
this.dataRows =数据;
}
https://stackoverflow.com/questions/54303105
复制相似问题