- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 Angular Material 数据表时遇到以下错误。我能够从api获取数据,但无法在 View 中呈现它。
错误:
error Image
TS:
dataSource = new MatTableDataSource();
displayedColumns: string[] = ["Part#", "Description"];
getSearchResult() {
let params = {
ParentCategoryID: 0,
CategoryID: 0,
ManufacturerID: 0,
};
this._httpService.getSearchResult(params).subscribe((resp: any) => {
this.searchResult = resp;
this.dataSource.data = this.searchResult;
});
}
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="Part#">
<th mat-header-cell *matHeaderCellDef> Part# </th>
<td mat-cell *matCellDef="let element "> {{element.PartCode}}
</td>
</ng-container>
<ng-container matColumnDef="Description">
<th mat-header-cell *matHeaderCellDef> Description </th>
<td mat-cell *matCellDef="let element ">
{{element.DiagramDescription}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
最佳答案
尝试将dataSource = new MatTableDataSource();
放入构造函数中:
constructor() {
dataSource = new MatTableDataSource();
}
关于angular - MatTableDataSource : cannot read property 'length' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52494919/
假设我有一个 mat-table,带有 mat-sort-header 和 matSort 来启用排序,还有 [数据源]="表格详细信息"。将数据提取到 sampleData 后,我使用以下内容初始化
我收到这样的错误: [ts] Argument of type 'Company' is not assignable to parameter of type 'Company[]'. Proper
我正在尝试使用 Angular Material Table 创建一个表,在示例中始终存在导入: import {MatTableDataSource} from '@angular/material
这是我的爱好项目,由于这个问题已经停滞了一段时间。这可能是一个简单的问题,但我对 Angular 和 JS 的了解相当有限。不过我的代码在下面(我已经缩短了一点)并且它在某种程度上起作用。它从服务器获
我从角度 4.4.6 和 Material beta 19 更新到角度 5 和 Material 5.0.0-rc0 应用程序编译正确,但我在 Chrome 上执行 "Uncaught Error:
我在使用 Angular Material 数据表时遇到以下错误。我能够从api获取数据,但无法在 View 中呈现它。 错误: error Image TS: dataSource =
我目前有一个数据表,其中填充了来自 Firestore 的数据。我还使用 MatTableDataSource 来实现分页、排序和过滤。所有 3 个都工作正常,但由于某种原因,我的数据只在页面刷新时加
我创建了一个 MatTableDataSource 实例,然后向其中添加数据并将其绑定(bind)到 mat-table。后来我对这个数据源应用了过滤器,它在 mat-table 中显示了过滤后的行。
我正在使用 Angular 5 开发一个 Angular 应用程序。我想使用 Angular-Material 中的“MatTableDataSource”。但我收到此错误 模块“AppModule”
在 Angular 材官网Angular Material Table提到 filterPredicate: ((data: T, filter: string) => boolean) 将根据特定字
我正在尝试在 Angular 7 中对表格 MatSort 进行排序,并且是 Angular 的新手。数据在数据源中并正确显示。我的数据来 self 调用后端的服务,然后我设置 this.dataSo
我们知道在 angular 中进行排序和分页很容易(仅考虑在客户端进行排序)。引用:https://stackblitz.com/angular/dnblbyvggqyj?file=src%2Fapp
我有一个 list ,它使用由 MatTableDataSource 提供的 mat-table 组件。 在 component.html 中 在 component.ts 中 dataSource
我正在尝试实现 如 Material Documentation 中所述 TL;DR: @angular/core, @angular/material, @angular/CDK升级到5版本后,突然
我是一名优秀的程序员,十分优秀!