0
我已经使用lodash模块如下组合:GROUPBY与Lodash模块
export class DtoTransactionCategory {
categoryName: String;
totalPrice: number;
}
GROUPBY
import { groupBy} from 'lodash';
let result = groupBy(transactionCategoryList, (c: DtoTransactionCategory) => {
return c.categoryName
});
结果:
所以现在我需要像这样得到上面的数组(即totalPrice
是group
的sum
):
let myNewArry = [{categoryName:"cat1",totalPrice: 9400},
{categoryName:"cat2",totalPrice: 600}]
你能告诉我如何实现最后一步?我在这里使用Lodash modules
。
终于拿到了solution.Thank你:) – Sampath