我有一个 mat-table 元素和mat-paginator下面的一个元素。该表填充了来自 API 的数据。默认情况下,我的 API 按请求返回 10 个元素,但我需要在表中显示 25 个元素,因此我需要发出 3 个 API 请求来填充 mat-table。
如何使用不同的参数重复调用 API,然后将所有三个响应合并为一个可观察值?
就我而言 - 我想getPlanetsPage(pageNumber)用不同的重复pageNumber,所以这是棘手的部分(我试图通过repeat()...解决这个问题):
return this.planetService.getPlanetsPage(dontKnowHowToDoItArg)
.pipe(
repeat(Math.ceil(this.paginator.pageSize / this.countOfPlanetsPerPage))
);
Run Code Online (Sandbox Code Playgroud)
ngAfterViewInit() 的完整代码:
this.paginator.page
.pipe(
startWith({}),
switchMap((paginatorData) => {
this.isLoadingResults = true;
const indexOfFirstElementToRenderInTable = this.paginator.pageSize * this.paginator.pageIndex;
if (this.planets[indexOfFirstElementToRenderInTable]) {
this.planetsToRender = this.planets.slice(indexOfFirstElementToRenderInTable, this.paginator.pageSize * (this.paginator.pageIndex + 1));
return EMPTY;
} else {
return this.planetService.getPlanetsPage(dontKnowHowToDoItArg)
.pipe(
repeat(Math.ceil(this.paginator.pageSize / this.countOfPlanetsPerPage))
);
}
}),
map(planetsPage => …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行 docker-compose build 并且遇到了这个问题:
=> ERROR [ 3/12] RUN apt-get update -qq && apt-get install -y nodejs postgresql-client libpng12-0 1.7s
------
> [ 3/12] RUN apt-get update -qq && apt-get install -y nodejs postgresql-client libpng12-0:
#6 1.665 W: GPG error: http://archive.debian.org/debian jessie Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010 NO_PUBKEY CBF8D6FD518E17E1
#6 1.665 E: The repository 'http://archive.debian.org/debian jessie Release' is not signed.
------
executor failed running [/bin/sh -c apt-get …Run Code Online (Sandbox Code Playgroud)