gpt4 book ai didi

angular - 具有静态数据的 Material Design 数据表布局

转载 作者:太空狗 更新时间:2023-10-29 17:56:18 32 4
gpt4 key购买 nike

如何在没有数据源(静态数据)的情况下使用 Material Design 数据表布局?我在 https://material.angular.io/components/table/examples 上找不到此用例的示例.例如,我尝试了以下但没有成功。

<mat-table>
<mat-header-row>
<mat-header-cell>One</mat-header-cell>
<mat-header-cell>Two</mat-header-cell>
</mat-header-row>
<mat-row>
<mat-cell>aaa</mat-cell>
<mat-cell>bbb</mat-cell>
</mat-row>
</mat-table>

我收到以下错误:

LeistungenComponent.html:195 ERROR Error: StaticInjectorError(AppModule)[MatCell -> CdkColumnDef]: 
StaticInjectorError(Platform: core)[MatCell -> CdkColumnDef]:
NullInjectorError: No provider for CdkColumnDef!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:979)
at resolveToken (core.js:1232)
at tryResolveToken (core.js:1182)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1077)
at resolveToken (core.js:1232)
at tryResolveToken (core.js:1182)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1077)
at resolveNgModuleDep (core.js:9238)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:9919)
at resolveNgModuleDep (core.js:9238)

最佳答案

在你的 app.module.ts 中,添加到 providers

providers:[CdkColumnDef]

添加到导入

import { CdkColumnDef } from '@angular/cdk/table';

关于angular - 具有静态数据的 Material Design 数据表布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51188105/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com