Browse Source

[完善] 分页module完善

master
陈鹏飞 4 years ago
parent
commit
f37be8e982
  1. 29
      src/app/ui/paginator/my-paginator.ts
  2. 13
      src/app/ui/paginator/paginator.module.ts
  3. 5
      src/app/ui/ui.module.ts

29
src/app/ui/paginator/my-paginator.ts

@ -0,0 +1,29 @@
import { MatPaginatorIntl } from '@angular/material/paginator';
const dutchRangeLabel = (page: number, pageSize: number, length: number) => {
if (length === 0 || pageSize === 0) { return `0 到 ${length}`; }
length = Math.max(length, 0);
const startIndex = page * pageSize;
const endIndex = startIndex < length ?
Math.min(startIndex + pageSize, length) :
startIndex + pageSize;
return `${startIndex + 1} - ${endIndex} / ${length}`;
}
export function myPaginator() {
const paginatorIntl = new MatPaginatorIntl();
paginatorIntl.itemsPerPageLabel = '每页条数:';
paginatorIntl.nextPageLabel = '下一页:';
paginatorIntl.previousPageLabel = '上一页:';
paginatorIntl.getRangeLabel = dutchRangeLabel;
return paginatorIntl;
}

13
src/app/ui/paginator/paginator.module.ts

@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatPaginatorIntl, MatPaginatorModule } from '@angular/material/paginator';
import { myPaginator } from './my-paginator'
@NgModule({
imports: [
CommonModule,
MatPaginatorModule
],
providers: [ { provide: MatPaginatorIntl, useValue: myPaginator() } ]
})
export class PaginatorModule { }

5
src/app/ui/ui.module.ts

@ -67,7 +67,7 @@ import { LookMaster } from './basicinfo/lookmaster.component';
import { CollectionToolsComponent, CreateBuilding, EditBuilding, ViewDetails } from './collection-tools/collection-tools.component';
import { WorkingAreaComponent } from '../working-area/working-area.component';
import {leftFunctionalDomainComponent,editPlaneFigureComponent} from './collection-tools/leftFunctionalDomain'
import { PaginatorModule } from './paginator/paginator.module';
@NgModule({
declarations: [UserdataComponent, ChangepasswordComponent, IsnoPipe, ConfirmpswDirective, TimePipe, EditUser, BasicinfoComponent, PlanComponent, AllaroundComponent, FireFightingDeviceComponent, KeySiteComponent, FunctionDivisionComponent, RealisticPictureComponent, UploadingCADComponent, AddHouseInfo, ImgDetails, ImagesData, ImgsDataDetail, KeySiteImgs, KeyImgDetail, addPartition, addPartitionAttribute, previewImg, addRealPicture, editRealPicture, readFile, editFile, LookMaster, previewBigImg, CollectionToolsComponent, WorkingAreaComponent,CreateBuilding,EditBuilding,leftFunctionalDomainComponent,editPlaneFigureComponent,ViewDetails
],
@ -119,7 +119,8 @@ import {leftFunctionalDomainComponent,editPlaneFigureComponent} from './collecti
ScrollingModule,
ReactiveFormsModule,
FormsModule,
FileUploadModule
FileUploadModule,
PaginatorModule
]
})

Loading…
Cancel
Save