我有一个问题,我不知道如何从我的组件中解决它我发送一个 Resource 数组,以便另一个组件读取它并将其注入到由 mat-table 读取的 DataSource 中。查阅了Angular的文档,我发现它是正确的。我不知道它是否是 html 中不允许我看到的内容。有人可以告诉我原因吗?
太感谢了
我的 .ts
@Input() resources : Resource [];
public dataSource = new MatTableDataSource <Resource> ();
public ngOnInit(): void {
console.log(this.resources)
this.dataSource.data = this.resources
}
我的.html
<mat-table class="resources-table" #table [dataSource]="resources" matSort [@animateStagger]="{value:'50'}" fusePerfectScrollbar>
<!-- ID Column -->
<ng-container matColumnDef="_id">
<mat-header-cell *matHeaderCellDef mat-sort-header>ID</mat-header-cell>
<mat-cell *matCellDef="let resource">
<p class="text-truncate">{{resource._id}}</p>
</mat-cell>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header>{{'RESOURCE.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let resource">
<p class="text-truncate">{{resource.name}}</p>
</mat-cell>
</ng-container>
</mat-table>
console.log(this.resources)
是img: