0
我正在使用最新的ng2-pagination(0.4.1)和angular2-webpack-starter(5.0.5)。不能使用ng2-pagination with angular2-webpack-starter
我的目標是嘗試ng2-pagination
。
我遵循以下步驟:
- 使用
npm install ng2-pagination --save;
- 加入
import 'ng2-pagination'
到vendor.browser.ts
ng2-pagination
安裝; 新增
import {Ng2PaginationModule} from 'ng2-pagination';
到app.module.ts
,然後將Ng2PaginationModule
加到它的進口數組中;改變
detail.component.ts
像這樣:import { Component } from '@angular/core'; @Component({ selector: 'detail', template: ` <h1>Hello from Detail</h1> <ul> <li *ngFor="let item of collection | paginate: { itemsPerPage: 10, currentPage: p }">{{ item }}</li> </ul> <pagination-controls (pageChange)="p = $event" #api> </pagination-controls>` }) export class Detail { collection = []; constructor() { for (let i = 1; i <= 100; i++) { this.collection.push(`item ${i}`); } } }
我得到以下錯誤:
EXCEPTION: Uncaught (in promise): Error: Template parse errors:
The pipe 'paginate' could not be found
It seems to me that the component doesn't know about ng2-paginate: what am I missing?