gpt4 book ai didi

angular4-forms - 在角度 4 中进行分页时出错

转载 作者:行者123 更新时间:2023-12-05 08:41:34 24 4
gpt4 key购买 nike

我是 Angular 4 的新手。我正在使用 Angular 4 进行分页。我已经安装了“npm install ngx-pagination --save”。我按照互联网上的说明进行操作。但我收到类似“找不到管道‘分页’(” ]游戏的游戏|分页:{itemsPerPage:2,currentPage:p}“> {{我}} "): ng:///ActivityChartModule/ActivityComponent.html@235:32 'pagination-controls' 不是已知元素:”。我尝试了更多。任何人都可以帮助我解决这个问题。下面是我的代码,

app.module.ts
import {NgxPaginationModule} from 'ngx-pagination';
imports: [NgxPaginationModule]

in component.ts
p: number = 1;


games = [
{
"id": "1",
"name": "DOTA 2",
"genre": "Strategy"
},
{
"id": "2",
"name": "AOE 3",
"genre": "Strategy"
},
{
"id": "3",
"name": "GTA 5",
"genre": "RPG"
},
{
"id": "4",
"name": "Far Cry 3",
"genre": "Action"
},
{
"id": "5",
"name": "GTA San Andreas",
"genre": "RPG"
},
{
"id": "6",
"name": "Hitman",
"genre": "Action"
},
{
"id": "7",
"name": "NFS MW",
"genre": "Sport"
}, {
"id": "8",
"name": "Fifa 16",
"genre": "Sport"

}, {
"id": "9",
"name": "NFS Sen 2",
"genre": "Sport"

}, {
"id": "10",
"name": "Witcher Assasins on King",
"genre": "Adventure"
}

];

in component.html
<div class="container">
<div class="row">
<nav class="navbar">
<input class="form-control" type="text" name="search">
</nav>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Genre</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let game of games | paginate: { itemsPerPage: 2, currentPage: p }">
<td>{{i}}</td>
<td>{{game.name}}</td>
<td>{{game.genre}}</td>
</tr>
</tbody>
</table>
<div>
<pagination-controls (pageChange)="p($event)"></pagination-controls>
</div>
</div>
</div>

最佳答案

如果你已经将 NgxPaginationModule 导入到 app.module.ts 中,我认为这是因为你需要在 npm install 后重新启动你的项目。尝试 ctrl+c 和 ng serve 重新启动它。

关于angular4-forms - 在角度 4 中进行分页时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48798700/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com