垫表不能绑定数据源 [英] mat-table can't bind dataSource

查看:65
本文介绍了垫表不能绑定数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用角度材质表MatTableModule,但是将数据传递到[dataSource]输入时,出现了Can't bind to 'dataSource' since it isn't a known property of 'table'.错误.我已经导入了MatTableModule,并且正如GitHub问题#5577所指出的那样,我也导入了CdkTableModule,但仍然没有运气.有什么想法吗?

I am trying to use angular material table MatTableModule, but when passing the data to the [dataSource] input I am getting the Can't bind to 'dataSource' since it isn't a known property of 'table'. error. I have already imported the MatTableModule and as pointed at GitHub issue #5577 also imported CdkTableModule but still no luck. Any ideas?

推荐答案

问题是我正在使用的材质角度版本为v5.2.4,因此根据Angular,模板应为<mat-table #table [dataSource]="dataSource"></mat-table>而不是<table mat-table #table [dataSource]="dataSource"></table>材料v5.2.4文档. https://v5.material.angular.io/components/table/overview#1-write-your-mat-table-and-provide-data

The problem was that the material angular version I'm using is v5.2.4, so the template should be <mat-table #table [dataSource]="dataSource"></mat-table> instead of <table mat-table #table [dataSource]="dataSource"></table> according to Angular material v5.2.4 documentation. https://v5.material.angular.io/components/table/overview#1-write-your-mat-table-and-provide-data

这篇关于垫表不能绑定数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆