Hi
I am able to get the sum in the HTML correctly with following codes:
<ion-item type="text" formControlName="billValue" [(ngModel)]="retailerItemModel" name="billValue" ngDefaultControl >Total Bill Value Rs. {{ totalValue(retailerItemModel) || 0 | number: '1.2-2' }}
</ion-item>
I am using Firebase to save data with AngularFire service provider:
saveBill(billValue: any =[], ): firebase.Promise<any>{
return this.afDatabase.list(`userProfile/${this.userId}/billList/`).push({
billValue,
})
}
The problem is after saving the firebase data shows array:
I want the sum of selected values to show not the array… Is there any way to do the calculation in HTML itself or controller for selected value… Following is the controller formula:
totalValue(retailerItemModel: any=[]){
let total = 0;
retailerItemModel.forEach((item) => {
total += Number(item);
})
return total;
}