Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda