angular 2 how to sum column ngFor

后端 未结 2 1503
渐次进展
渐次进展 2021-02-11 06:02

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:48

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

提交回复
热议问题