ng-devui-materials
Version:
Materials of DevUI Admin
56 lines (44 loc) • 1.08 kB
text/typescript
import { Component, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { ListDataService } from './list-data.service';
export class CardListComponent implements OnInit {
cardList = [];
pager = {
total: 0,
pageIndex: 1,
pageSize: 12,
};
pageSizeOptions = [6, 12, 24];
keyword = '';
busy: Subscription;
constructor(private listDataService: ListDataService) {}
ngOnInit() {
this.getList();
}
search() {
this.getList();
}
getList() {
this.busy = this.listDataService
.getCardSource(this.pager)
.subscribe((res) => {
this.pager.total = res.total;
this.cardList = res.pageList.filter((i) => {
return i.name.toUpperCase().includes(this.keyword?.toUpperCase());
});
});
}
onPageChange(e) {
this.pager.pageIndex = e;
this.getList();
}
onSizeChange(e) {
this.pager.pageSize = e;
this.getList();
}
}