Mat-paginator length is not working.Not able to set it

I am trying to call API on the click of pagination. Initially, I had set the length statically and it was working fine. I was able to do a pagination API call.And then I had tried to set the length dynamically as well and it worked too, but later on, it stopped working. Please help me to point out my mistake.
I am setting the length of content in this.totalEmp and able to print it on html side as well but when I am trying to set in mat-paginator for [length]. It is not working for me.I tried to set #paginator in mat-paginator as well but no change was seen.

Below is my implementation    

<mat-paginator [length]=“totalEmp” [hidden]=“normalPagination” [pageSize]=“2” [pageSizeOptions]="[2]" [pageIndex]=“pageIndex” (page)=“pageEvent = getDataByPagination($event)”>

**.ts file Code**

export class EmpComponent implements OnInit {
         dataSource: any;
         totalEmp: number=0;
         normalPagination: boolean;
        @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
         @ViewChild(MatSort, { static: true }) sort: MatSort;
        ngOnInit() {
         getTableContentCount() {
              (response: any) => {
                if (response) {
                  this.totalEmp = response;
              (error: any) => { }
        public getDataByPagination(event?: PageEvent) {
      response => {
        if (response) {
 = this.totalEmp;      
          this.dataSource = new MatTableDataSource(this.allData);
          this.dataSource.paginator = this.paginator;
          this.dataSource.sort = this.sort;
      error => {
        // handle error
    return event;