【发布时间】:2020-07-09 21:25:59
【问题描述】:
我必须对 post 函数的结果进行排序。 有post功能:
findQuotation(queryParams: QueryParamsModel): Observable<QueryResultsModel> {
return this.http.post<QueryResultsModel>(API_QUOTATIONS_URL + '/list', queryParams);}
这些返回给我一个对象数组,比如
this
我在ngrx效果中这样调用服务的函数:
@Effect()
loadRolesPage$ = this.actions$
.pipe(
ofType<QuotationsPageRequested>(QuotationActionTypes.QuotationsPageRequested),
mergeMap(({ payload }) => {
this.store.dispatch(this.showPageLoadingDistpatcher);
const requestToServer = this.quotationService.findQuotation(payload.page);
const lastQuery = of(payload.page);
return forkJoin([requestToServer, lastQuery]);
}),
map(response => {
console.log('response', response);
const result: QueryResultsModel = response[0];
const lastQuery: QueryParamsModel = response[1];
this.store.dispatch(this.hidePageLoadingDistpatcher);
return new QuotationsPageLoaded({
quotations: result.items,
totalCount: result.totalCount,
page: lastQuery
});
}),
);
我想根据最近的 created_at(Date object) 对这个服务器响应进行排序。
【问题讨论】:
-
按这些排序??日期或报价单或 ID??
-
并且还包括你在服务中调用这个函数的代码..
-
@Supercool。对不起,我剪掉了我的一部分帖子。我想按 created_at(日期)排序
标签: javascript arrays angular sorting object