I need to prevent entering same value for two different text boxes

this is my code.

```
<input type="text"  required [(ngModel)]="passwordModel.oldPassword" name="oldPassword" #oldPassword="ngModel" class="form-control" id="inputPassword" placeholder="Current Password">

<input type="text" (keydown)='ngModelChange()' required class="form-control" id="newinputPassword" [(ngModel)]="passwordModel.newPassword" name="newPassword" #newPassword="ngModel" placeholder="New Password">

```

function

```
checkModelVal() {
  this.oldPw = this.passwordModel.oldPassword,
  this.newPw = this.passwordModel.newPassword;
  if (this.oldPw === this.newPw ) {
    console.log('new and old password can not be same');
  }
}

```

above code may be bad solution for the my requirement. if you know any better solution, please mention in the answer. thanks