2017-07-27 42 views
1

我目前正在從服務器使用Spring MVC和Angular獲取的數據,以完成工作,但是當我嘗試更改時遇到問題這一頁。服務器端分頁[春季MVC和角4]

PROFIL-management.component.html

   <tr 
       *ngFor="let profil of profilList | paginate: { id:'profils_pages', itemsPerPage: pageSize, currentPage: p, totalItems: totalObjectCount } "> 
       <td><a (click)="onSelect(profil)" data-toggle="modal" data-target="#myModal2" 
        style="text-decoration: none; cursor: pointer">{{profil.eprLabel}}</a> 
       </td> 
       <td> 
       <button type="submit" class="ti-pencil" (click)="onSelectUpdate(profil)" data-toggle="modal" 
         data-target="#myModal"></button> 
       </td> 
       <td> 
       <button type="submit" class="ti-trash" data-toggle="modal" data-target="#deleteModal" 
         (click)="onSelect(profil)"></button> 
       </td> 
      </tr> 
      <div style="text-align: center; margin-left: 35%; margin-top: 3%;"> 
       <pagination-controls id="profils_pages" 
            maxSize="10" 
            (pageChange)="p = getServerData($event)" 
            directionLinks="true" 
            autohide="true"> 
       </pagination-controls> 

我認爲這個問題是在getServerData(事件)

PROFIL-management.component.ts

getServerData(event) { 
    this.profilManagementService.getProfilsPagination(event - 1).subscribe(
    res => { 
    this.profilList = res.json().ecomProfils; 
    }, error => { 
    } 
    ); 
} 

enter image description here

enter image description here

分頁光標並沒有改變但它從服務器帶來了第二頁。

我在此代碼中使用ngx-pagination

回答

0

您需要從「getServerData」函數返回事件。事件只不過是一個分頁控制指令中分配給p變量的頁碼。