angular - Getting error "Property 'tpl' does not exist on type 'ListComponent'." using Angular material table
问题描述
I am getting the following error while implementing the angular material table.
Error:
Property 'tpl' does not exist on type 'ListComponent'.
I am explaining my code below.
<div class="mt-9">
<table mat-table [dataSource]="dataSource" matSort (matSortChange)="sortChange($event)">
<tr mat-header-row *matHeaderRowDef="displayColumns(); sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayColumns();" matRipple class="element-row"
[cdkDetailRow]="row" [cdkDetailRowTpl]="tpl"></tr>
</table>
<div *ngIf="!dataSource || dataSource?.length === 0" class="text-center mt-5 text-danger">
<h6>No records found</h6>
</div>
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" [pageSize]="pageSize" [pageIndex]="pageIndex"
[length]="totalCount" (page)="pageChange($event)" showFirstLastButtons></mat-paginator>
</div>
Here I am using [cdkDetailRowTpl]="tpl"
and here that error is coming. I need some help to resolve this error.
解决方案
tpl
应该在您的列表组件中声明
列表组件:
export class ListComponent implements OnInit {
tpl: any;
constructor() { }
ngOnInit() {
}
}
推荐阅读
- javascript - 制作不和谐机器人时如何获取目标用户的标签?
- android - app:srcCompat 是否仍然需要最低 Android 支持 5.0?
- html - 当我放大时背景图像剪切
- aws-lambda - 如何动态地将 arn cognito 添加到 lambda?
- django - 如何为 ModelResource 中的 row_result 差异列表强制执行静态顺序?
- azure - NSG 是否适用于子网的服务端点
- java - gradle build 尝试合并 dex 档案失败
- python - 如何从 csv 文件的某些列中删除 NaN 值?
- python - 为什么带有稀疏列的 pandas 数据框会占用更多内存?
- c++ - 转发模板优先于过载