定义各种属性
pageIndex = 1; //现在的页数
itemsPerPage = 12; //每页显示的数量
totalPages = 1; //总页数
frontPaginationDisabled = false; //是否是第一页
rearPaginationDisabled = false; //是否是最后一页
显示该页的数据
showCities(): City[]{
if(this.webService.Cities !== null && this.webService.Cities.length > 0){
console.log('update cities');
const firstIndex = (this.pageIndex-1)*this.itemsPerPage; //第一个显示的数据
const endIndex = this.pageIndex * this.itemsPerPage; //最后一个显示的数据
return this.webService.Cities.slice(firstIndex,endIndex); //切出需要显示的数据
}
}
检查时候到了最后一页
noMorePage(){
return this.pageIndex*this.itemsPerPage>=this.webService.Cities.length;
}