3
@ViewChild('paginator', {static: true}) paginator:Paginator;

this paginator is undefined when I console in ngOnInit function.

why?

I tried to print prime-ng paginator in component file with using view child.but it's getting undefined.

Brandon Taylor
  • 33,823
  • 15
  • 104
  • 144

1 Answers1

1

You have to add any logic you want to perform inside of ngAfterViewInit callback. During ngOnInit the the template isn't fully rendered yet.

O.MeeKoh
  • 1,976
  • 3
  • 24
  • 53