我安裝了一個簡單的分頁組件的ng2-bootstrap。從文檔(https://valor-software.com/ng2-bootstrap/#/pagination#pager-component)設置組件看起來很簡單。分頁與角2無法設置每頁項目
但是,我無法設置每頁的項目。我跟着示例和進口像這樣
PaginationModule.forRoot(),
模塊I加入必要的屬性
maxSize:number = 5;
bigTotalItems:number = 726;
bigCurrentPage:number = 1;
numPages:number = 0;
itemsPerPage: number = 10; // **** this is the one not working
我添加了選擇器和屬性等的文檔顯示
<pagination
class="pagination-sm"
[totalItems]="bigTotalItems"
[(ngModel)]="bigCurrentPage"
[maxSize]="maxSize"
[boundaryLinks]="true"
[rotate]="false"
[itemsPerPage]="itemsPerPage"
(numPages)="numPages = $event">
</pagination>
一切顯示出來,但頁面不限於10.所有內容都顯示在一頁上。
在用於節點模塊/ github上頁組分(https://github.com/valor-software/ng2-bootstrap/blob/development/src/pagination/pagination.component.ts)每頁項目被構造像這樣
this.itemsPerPage = typeof this.itemsPerPage !== 'undefined'
? this.itemsPerPage
: this.config.itemsPerPage;
我確信我的分頁選擇器正下方的裝飾
*ngFor
我只是不知道爲什麼我無法正確設置項目頁面。
'itemsPerPage:number = 10;'而不是-10 – Habeeb
深夜類型在我的部分。我的組件具有正確的語法。我改變了我的答案以匹配。 – Winnemucca