I have a simple list where I want to optimize my code by only updating the admin2
object once. The goal is for admin2
to be set equal to (property) Admin2Component.admin2: IAdmin2
:
In simpler terms, I need to update this admin2
with three different pagination objects: projectPagination, consultantPagination, and newsletterPagination.
private updateList(
projectPagination: IPaginationResponse <IProject>,
consultantPagination: IPaginationResponse <IConsultant>,
newsletterPagination: IPaginationResponse <INewsletter>
) {
this.admin2 = projectPagination.data;
this.pagination.total = projectPagination.meta.pagination.total;
this.pagination.page = projectPagination.meta.pagination.current_page;
this.admin2 = consultantPagination.data;
this.pagination.total = consultantPagination.meta.pagination.total;
this.pagination.page = consultantPagination.meta.pagination.current_page;
this.admin2 = newsletterPagination.data;
this.pagination.total = newsletterPagination.meta.pagination.total;
this.pagination.page = newsletterPagination.meta.pagination.current_page;
}
Later on:
$onInit() {
console.log(this.projectPagination, this.consultantPagination,
this.newsletterPagination);
this.updateList(
this.projectPagination,
this.consultantPagination,
this.newsletterPagination
);
}