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

前端 未结 10 2112
南方客
南方客 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 01:04

    • Angular Core v6.0.2,
    • Angular Material, v6.0.2,
    • Angular CLI v6.0.0 (globally v6.1.2)

    I had this issue when running ng test, so to fix it, I added to my xyz.component.spec.ts file:

    import { MatTableModule } from '@angular/material';

    And added it to imports section in TestBed.configureTestingModule({}):

    beforeEach(async(() => {
        TestBed.configureTestingModule({
          imports: [ ReactiveFormsModule, HttpClientModule, RouterTestingModule, MatTableModule ],
          declarations: [ BookComponent ],
          schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
        })
        .compileComponents();
    }));
    

提交回复
热议问题