Can't bind to 'dataSource' since it isn't a known property of 'table'

前端 未结 10 2145
南方客
南方客 2020-12-03 00:32

I am new in angular 5 development. I am trying to develop a data table with angular material using the example provided here: \"https://material.angular.io/components/table/

10条回答
  •  时光说笑
    2020-12-03 00:58

    if your "import { MatTableModule } from '@angular/material';" is on a shared module, make sure you export it.

    sharedmodule.ts:

    import { MatTableModule } from '@angular/material' 
    
    @NgModule({
      imports: [
        // ...
        MatTableModule
        // ...
      ],
      exports:[ MatTableModule ]
    })
    

    then on your custom module where you define the component that use material table:

    custommodule.ts:

    @NgModule({
    imports: [ sharedmodule ]     
    })
    

提交回复
热议问题