I am trying to sum up the values entered in the mat-table
column using an input.
I have created a table with 3 columns: Account Id
, A
try this
In component
ngOnInit(){
this.accdetailservice.accountdetails()
.subscribe(data =>
this.dataSource1.data= data.map(obj => ({...obj, value: 0}))
);
}
calculation(){
return dataSource1.data.reduce((summ, v) => summ += parseInt(v.value), 0)
}
in Html
Total: {{calculation()}}
also change to
as per the chat discussion you need to use value parameter as a dynamic parameter to calculate
So try this below way
Value