1

I am trying to export a module from my material.module.ts while creating a mat table. But it doesn't display anything when I run the localhost as it gives the following error. How can I fix this out?

Uncaught Error: Can't export directive MatPaginator from MaterialModule as it was neither declared nor imported!

material.module.ts


import {NgModule} from '@angular/core';
import {
  MatAutocompleteModule,
  MatBadgeModule,
  MatBottomSheetModule,
  MatButtonModule,
  MatButtonToggleModule,
  MatCardModule,
  MatCheckboxModule,
  MatGridListModule,
  MatIconModule,
  MatInputModule,
  MatListModule,
  MatMenuModule,
  MatTableDataSource,
  MatPaginatorModule,
  MatRadioModule,
  MatTableModule,
  MatPaginator,
} from '@angular/material';

@NgModule({
  exports: [
  MatAutocompleteModule,
  MatBadgeModule,
  MatBottomSheetModule,
  MatButtonModule,
  MatButtonToggleModule,
  MatCardModule,
  MatCheckboxModule,
  MatGridListModule,
  MatIconModule,
  MatInputModule,
  MatListModule,
  MatMenuModule,
  MatTableDataSource,
  MatPaginatorModule,
  MatRadioModule,
  MatTableModule,
  MatPaginator,
  ]
})
export class MaterialModule {}


CodeBunny
  • 21
  • 2
  • 6

1 Answers1

2

exports: [ ...
MatPaginator ]

You export modules - not directives, components etc. MatPaginator is not a module so it can't be exported. You also export MatPaginatorModule which is what you need.

G. Tranter
  • 16,766
  • 1
  • 48
  • 68
  • So you mean I have to remove MatPaginator from exports and should export MatPaginatorModule instead? – CodeBunny May 16 '19 at 06:13
  • 1
    Yes - remove MatPaginator - but you are already exporting MatPaginatorModule - so you don't need to add it a second time. – G. Tranter May 16 '19 at 13:45