*ngIf problem with my ion-input

Hello there, anyone can help me with this?
I want to check for duplicate username on my ion-input and show “Username is taken.” when there is duplicate username found in my firebase. I’ve used the *ngIf for this, but I encountered a problem which that the *ngIf would not be gone even when I’ve entered the correct username. Please help me with this.
image
Thank you in advance :slight_smile:

  • For your information, here is my code:
<ion-input (ionChange)="checkForUser(username)" [(ngModel)]="username" name="username" type="text" placeholder="NRIC as username" formControlName="username"></ion-input>
                <p *ngIf="checkForUsername" style="color: red;">Username is taken.</p>
   checkForUser(username){
      this.checkForUsername;
      this.users.subscribe(item=>{
          for(var i=0; i<item.length;i++){
              if(this.username.toLowerCase() === item[i].username.toLowerCase()){
                  this.checkForUsername = !this.checkForUsername;
              }
          }
      })
  }

Post your Code, else we can’t see what you’re doing wrong.