0

Below is my .html file

<div class="p-field p-grid">
            <label for="username" class="p-col-fixed" style="width: 100px;">Username</label>
            <div class="p-col">
                <input 
                type="text" 
                id="username" 
                name="username"
                ngModel
                required
                pInputText
                #username="ngModel"
                (keypress)="enterkeypress($event)"
                >
                <span class="help-block" *ngIf="!username.valid && username.touched">Please enter an username!</span>
            </div>
            </div>

Below is my .ts file (showing only enterkeypress function)

enterkeypress(e) {
        console.log(e.target.value);
    }

Output

When i Entered the word R its showing me Empty output enter image description here

When i Entered the second word T its showing me previous output R enter image description here

And So ON, its always giving me previous value instead of current value enter image description here

Please Help!!!!!!!! Thanks in Advance

Ashish Ahuja
  • 472
  • 5
  • 10

0 Answers0