angular - pagination ngx bootstrap for angular2 -
i have probleme pagination first have 21 objects in database when them want show them pagination , things works think pagination module has number of row display default took 10 row per page , not 4 per page
export class groupcomponent implements oninit { public maxsize:number = 5; bigtotalitems:number = 175; bigcurrentpage:number = 1; numpages:number = 0; itemsperpage = 4; groups : any; myvar:boolean=false; constructor(private groupeservice:dataserviceservice) { parent.displaygroupeicon(); } ngoninit() { this.getlistgroups(); } getlistgroups(){ this.groupeservice.getgroupsbypageandsize(this.bigcurrentpage-1,this.itemsperpage).subscribe(groups => { this.groups=groups; this.numpages=groups.totalpages; this.bigtotalitems=groups.totalelements; this.myvar = true; }); }
and template
<table class="table table-striped"> <thead> <tr> <th >identifiant </th> <th >nom </th> <th >image</th> <th ></th> <th ></th> </tr> </thead> <tbody *ngif="myvar"> <tr *ngfor="let groupe of groups.content" > <td >{{groupe.idgroupe}} </td> <td >{{groupe.nom}} </td> <td >{{groupe.imageurl}}</td> <td ><button class="btn btn-warning" >update <i class="fa fa-cog" aria-hidden="true"></i></button></td> <td ><button class="btn ink-reaction btn-danger">delete <i class="fa fa-trash-o" aria-hidden="true"></i></button></td> </tr> </tbody> </table> <div class="col-md-6"> <pagination [totalitems]="bigtotalitems" [(ngmodel)]="bigcurrentpage" [maxsize]="maxsize" class="pagination-sm" [boundarylinks]="true" [rotate]="false" (click)="getlistgroups()"></pagination> </div> bigtotalitems : {{bigtotalitems| json}} numpages : {{numpages|json}}
i resolv adding [itemsperpage]="itemsperpage" directive in selector of pagination
Comments
Post a Comment