I have an Angular form initialized with something like this
buildForm() {
this.form = this.formBuilder.group({
value1: this.formBuilder.control(null),
value2: this.formBuilder.control(false)
});
}
and I use a [required]
in the tag in the html where I have two conditions, first is an object with a true/false required and the second being another value in the form (which can be updated in the ts or by a user).
<div [formGroup]="form">
<div *ngIf="valuesObject.value1.display">
<mat-form-field>
<mat-select formControlName="value1"
[required]="valuesObject.value1.required || form.value.value2">
<mat-option [value]="null"> empty <mat-option>
<mat-option [value]="1"> option 1 <mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
Every time the [required]
flips from false -> true or true -> false, it sends an event to my form.valueChanges
which then sends a call to the server because it thinks that data has been updated. Is there a way to ignore this event or capture it so I can set a flag to ignore it within the .valueChanges
?