Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
Get/subtract current value from an input tag Angular/Typescript

I am trying to dynamically update a sum of two fields in angular based on user input. At first it is linked to some data taken from the database. I managed to change the input and update the sum, but I somehow need to subtract what was before in the field in sum calculation. Now the sum adds also what was previously in the field and I don't want that behaviour.

.html file

<div class="d-flex justify-content-center">
    <form>
        <input class = "textbox" type="text" name="Name" [ngModel]="user._30_geplant (change)="updateSum($any($event.target).value)">
    </form>
</div>
<div class="d-flex justify-content-center">
    <form>  
        <input class = "textbox" type="text" name="Name" [ngModel]="user._30_buro (change)="updateSum($any($event.target).value)">
    </form>
</div>
<div class="d-flex justify-content-center">
    <p class = "delta" [ngModel]="delta30" ngDefaultControl>{{delta30}}</p>
</div>

In the .ts file

constructor() {
    this.delta30 = this.user._30_geplant + this.user._30_buro;
}

updateSum(sum: number) {
   this.delta30 = (+this.delta30) + (+sum);
}

What I have tried so far seemed not to work.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!