我有一个产品数组,其字段名称为 ID、品牌、价格、数量销售、价值,其中价值 = 价格 * 数量出售,最后我需要显示商品数量、销售总量和总销售价值
@Component
({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
}`
export class AppComponent{
allProduct:Product[]=[
{Id:'P104', Brand:'Pepsi',Price:4,qtySold:22},
{Id:'C124', Brand:'Coke',Price:4,qtySold:26},
{Id:'M155', Brand:'Maggie',Price:6,qtySold:10},
{Id:'DM241', Brand:'Cadburys',Price:10,qtySold:15},
{Id:'5S118', Brand:'5 Star',Price:8,qtySold:8},
];
需要显示产品数量、销售数量和销售价值总和