I am trying to achieve pagination for the mat-table. But i am getting this.paginatior is undefined when I console the paginatior variable.

```
import { MatPaginator, MatTableDataSource } from '@angular/material';

export class DataComponent implements OnInit{
    public dataSource:MatTableDataSource<any>;
    @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
    ngOnInit() {
        this.fetchdata.getdata().subscribe(result=>{
             let resultData = result.data;
             this.dataSource = new MatTableDataSource(resultData);
             this.dataSource.paginator = this.paginator;
        });
    }
}

```

In HTML

```
<mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator>

```