首页 > 解决方案 > 错误错误:未捕获(承诺):错误:模板解析错误:无法绑定到“数据源”,因为它不是“垫表”的已知属性

问题描述

core.js:15724 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'dataSource' since it isn't a known property of 'mat-table'.
    1. If 'mat-table' is an Angular component and it has 'dataSource' input, then verify that it is part of this module.

    2. If 'mat-table' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
      [@animate]="{ value: '*', params: { scale: '.9', delay: '300ms' } }"
    >
      <mat-table [ERROR ->][dataSource]="countryTrafficStats" matSort>
        <ng-container matColumnDef="country">
          <"): ng:///OthersModule/AppBlankComponent.html@32:17
'mat-header-cell' is not a known element:

标签: angularangular-material

解决方案


尝试更换:

 <mat-table [dataSource]="countryTrafficStats" matSort>
...
</mat-table>

和:

<table mat-table [dataSource]="countryTrafficStats" matSort>
...
</table>

推荐阅读