Json 导航页面时使用ServerDataSource数据的ng2智能表未更改

Json 导航页面时使用ServerDataSource数据的ng2智能表未更改,json,angular,ng2-smart-table,Json,Angular,Ng2 Smart Table,我将ng2智能表与ServerDataSource一起使用,如下所示 this.source = new ServerDataSource(_http, { dataKey: 'data.data', endPoint: 'https://myapi?page=', pagerPageKey: 'data.meta.current_page', pagerLimitKey: 'data.meta.per_page', totalKey: 'data.meta.total'

我将ng2智能表与ServerDataSource一起使用,如下所示

this.source = new ServerDataSource(_http, {
  dataKey: 'data.data', 
  endPoint: 'https://myapi?page=', 
  pagerPageKey: 'data.meta.current_page',
  pagerLimitKey: 'data.meta.per_page',
  totalKey: 'data.meta.total',
});
在我的url上,我得到了这个
http://localhost:4200/pages/admin/users-list?page=1
但当我浏览页面时,即使我将url更改为其他页面,它也不会更改。如果我将api从
https://myapi?page=1
https://myapi?page=2
我知道我做错了什么,但它在哪里

编辑

我不知道这是否有效,但我想我需要通过收听页面更改事件来获取“当前页面”。所以现在我有以下代码:

this.source.onChanged().subscribe((change) => {
  if (change.action === 'page') {
    this.page = change.paging.page;
    this.userService.getAllUser(this.page).subscribe(
      (data:any)=>console.log(data.data.data)
    )
  }
});
我得到了我想要的结果,但问题是如何使用
this.page
myapi?page=
。有人有办法吗

编辑


我认为您需要更改数据源配置对象中的页面参数

 this.source = new ServerDataSource(_http, 
{
dataKey: 'data.data',
endPoint: 'https://myapi/endpoint',
pagerPageKey: 'page', // this should be page number param name in endpoint (request not response) for example 'page'
pagerLimitKey: 'your-endpoint-param-name-for-pageSize', // this should page size param name in endpoint (request not response)
totalKey: 'data.meta.total', // this is total records count in response , key seems right 
});
因此,您需要将pagerPageKey值更改为“page”,并将pagerpagelimit更改为您在端点中的键


无需处理此问题。source.onChanged()//删除此代码

是否已将角度路由器设置为接受页面ID?也许您可以在四处查看后共享您的路由设置,给定的url不是form
ServerDataSource
它来自我的api。所以我猜ServerDataSource不使用queryParams。但我仍然无法浏览页面。我也在akveo github问题中搜索过,我找到了这个,但我不知道它是否相关。这个页面是页面的编号吗?或者它包含页面的编号?是
this。page
是页面的编号如果我的后端接受此
myendpoint.com/api/data?page=1
我应该如何将其设置为配置?您应该传递与上述答案相同的对象,根据url参数,您应该使用值“page”设置参数“pagerPageKey”,,,“endPoint”到“”,“dataKey”到您的数据路径作为响应让我们说“data.records”,“totalKey”到您的记录总计数路径作为“data.totalcount”的响应返回很抱歉响应太晚,在我再次阅读后,我想我没有理解您的答案。你所说的“请求而不是响应”是针对我的配置,我没有意识到在我再次阅读后,我根据你的回答编辑了我的问题,对吗?我不需要PagerMitKey,所以我删除了它是的,您的配置根据您的url是正确的,您可以忽略“PagerMitKey”,如果它是从服务器“静态”设置的,您应该删除onsourceChanged,分页将从serverDataSource自动处理,仍然有任何问题吗?
 this.source = new ServerDataSource(_http, 
{
dataKey: 'data.data',
endPoint: 'https://myapi/endpoint',
pagerPageKey: 'page', // this should be page number param name in endpoint (request not response) for example 'page'
pagerLimitKey: 'your-endpoint-param-name-for-pageSize', // this should page size param name in endpoint (request not response)
totalKey: 'data.meta.total', // this is total records count in response , key seems right 
});