Angular interpolation not updated

Asked

Viewed 138 times

0

I’m learning angular and I’m having a difficulty, the program is very simple has a textInput and a paragraph, which if typing in the textInput should appear in the paragraph.

onKeyUp(evento: any){
     this.valorAtual = evento.target.value ;
     console.log(evento.target.value)
  }

         <input type="text"  (keyup)="onKeyUp($event)"   />

         <p> {{valorAtual}}</p>

The problem is that sometimes it works, other times it doesn’t just update once I don’t know what I’m doing wrong.

2 answers

1

I discovered the error, it was not in the code, my browser kept translating the page and when I put a text there was nothing there it could not translate.

0

All you had to do was use [(ngModel)]="valueAtual" in the textInput, which would already appear in the paragraph, without the need for the event.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.