samedi 28 novembre 2020

how to set condition for function call on checkbox click

I have a table which consists of columns named NoBill and Bill which has checkbox as values.

Table default view

When NoBill checkbox gets clicked once totale(this.totale) value gets calculated.

Totale value at top after two checkbox clicked in nobill column

When Bill column checkbox gets clicked once total(this.total) value gets calculated. It also opens two new columns named Ratio and Revasst.

Total value at top and ratio calculation here

The formula for getting value for Ratio is (total/totale). For example if total is 110 and if totale is 100 then the ratio is 110/100=1.1.

So when I click the same Bill column checkbox repeatedly(2 times to enable and disable) the value total(this.total) gets repeatedly calculated. So now the total value gets updated from 110 to 120. So because of that the Ratio value gets changed to 1.2 as now its 120/100 instead of 110/100. This is the issue I am facing.I just want the total value to be calculated only once for a single checkbox click. So that it stays 110 for that checkbox click eventhough its clicked multiple times. Ratio value change after clicking same checkbox value repeatedly

Kindly help me if you know the solution.

Note: If you have any doubts or if you feel my question was not clear please ask below in the comments.

My stackblitz link: https://stackblitz.com/edit/angular-ivy-qwwntr?file=src%2Fapp%2Fapp.component.ts

Ratio value change after clicking same checkbox value repeatedly




Aucun commentaire:

Enregistrer un commentaire