Angular 使用角度材质表获取错误“类型“ListComponent.”上不存在属性“tpl”
在实现“角度材质表”时,我遇到以下错误 错误: 类型“ListComponent”上不存在属性“tpl” 我在下面解释我的代码Angular 使用角度材质表获取错误“类型“ListComponent.”上不存在属性“tpl”,angular,angular-material-5,angular-material-table,Angular,Angular Material 5,Angular Material Table,在实现“角度材质表”时,我遇到以下错误 错误: 类型“ListComponent”上不存在属性“tpl” 我在下面解释我的代码 <div class="mt-9"> <table mat-table [dataSource]="dataSource" matSort (matSortChange)="sortChange($event)"> <tr mat-header-row *matHea
<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>
这里我使用的是[cdkDetailRowTpl]=tpl,而错误就在这里。我需要一些帮助来解决此错误。应该在列表组件中声明tpl
列表组件:
应该在组件中声明tpl您在列表中声明了tpl变量了吗component@HitechHitesh:否我尚未在我的list.componet.ts中声明。声明它并为其设置一个值,以便您的cdk可以获取值
export class ListComponent implements OnInit {
tpl: any;
constructor() { }
ngOnInit() {
}
}