我有以下代码,它从我的服务返回分页结果。我刚刚切换到 Angular 5,现在代码不再工作了
return this._http.get(
this.userManagerResourceApiUrl + "GetAllUsers/" + tierID + "/" + countryID + "/" + officeID + "/" + filter
).map((res: Response) => {
paginatedResult.result = res.json();
if (res.headers.get("Pagination") != null) {
var paginationHeader: Pagination = this.itemsService.getSerialized<Pagination>(JSON.parse(res.headers.get("Pagination")));
paginatedResult.pagination = paginationHeader;
}
this.totalItems = paginatedResult.pagination.TotalItems;
return paginatedResult;
}).catch(this.handleError);
我收到以下错误消息
Type 'Promise<any>' is not assignable to type 'IUser[]'
在 Angular 5 中,您不再需要映射到 json 并删除任何不再需要的
map(res => res.json())
调用。
将项目升级到 Angular 5 时需要注意的事项。 https://onlyforcoder.blogspot.in/2017/11/angular-5-upgrade-your-project-To-Angular5.html