Utilizing the angular material paginator has been a great experience for me. You can check it out here: https://material.angular.io/components/paginator/examples. The paginator triggers an event which allows me to print the page size and page index. This function is implemented in what I'll refer to as Component A.
paginate($event: PageEvent) {
concole.log($event.pageIndex);
console.log($event.pageSize);
}
In Component B, there are two variables named pIndex
and pSize
.
My objective is to assign these variables with values extracted from the PageEvent. However, the pageEvent occurs in Component A.
I attempted to include an event emitter in component A to broadcast the page size.
export class ComponentA {
@Output() pageSizeEmitter = new EventEmitter<number>();
paginate($event: PageEvent) {
this.pageSizeEmitter.emit($event.pageSize);
concole.log($event.pageIndex);
console.log($event.pageSize);
}
}
Nevertheless, in Component B, I face uncertainty on how to link it to the pSize
variable.
export class ComponentB {
pIndex: number = 0;
pSize: number = ?
}
Your suggestions and advice on this matter would be highly valued.