I have two different dropdowns (implemented a as a cihld components) with the same data inside.
I want to display mat-error if those two selected values are the same. On a mat-error tag, I call a function:
areValuesTheSame() {
if (this.form.controls['value1'].value && this.form.controls['value2'].value) {
return this.form.controls['value1'].value === this.form.controls['value2'].value;
}
I thought that I will get the result true/false and according to that in a mat-error I will do like this:
<mat-error *ngIf="areValuesTheSame()">Selected values has to be the same!</mat-error>
But the thing is, that it constantly returns the values for me instead of returning it one time (true or false).
If I try to check it in the console.log, the console prints the result n times (like an infinite loop).
What I'm doing wrong here?