angular 2 how to sum column ngFor

后端 未结 2 1123
野趣味
野趣味 2021-02-11 06:14

trying to understand how to sum the column from table, every is added with *ngFor ( like todo-list), i wanna sum one of column, how i can do it in angular 2 ? So i have table

2条回答
  •  渐次进展
    2021-02-11 06:51

    getSum(): number {
        let sum = 0;
        for (let i = 0; i < this.items.length; i++) {
          sum += this.items[i].num1;
        }
        return sum;
      }
    

提交回复
热议问题