Solution 1 :

On change event check whether there is a value for the other control too. Suppose datepicker change event is fired check if the select value is present. if yes then fire the function else do nothing. Same for the other control.

Solution 2 :

I can see you have added methods for onchange. Just call checkAvailability() inside setCheckToFalse() and Test() both, only when this.Datum and this.selectedLocation both have values.

Problem :

I have this HTML code where I have a datepicker and a select element. Right now I have a button which is connected to the method checkAvailability()

<div class ="d-flex flex-row bd-highlight mb-3">

    <div class = "form-froup row">
             
            <label class = "col-sm-2 col-form-label">Choose a date</label>
            <div class="col-sm-10"> 
                <input (change)="setCheckToFalse()" type ="date" class="form-control"[(ngModel)] = "Datum"
                    placeholder="dd-mm-yyyy">
                    </div>    
                        </div>
</div>
    </div>

    <div class="form-group">
        <label for="exampleFormControlSelect1">Choose a location</label>
        <select (change)=Test() [(ngModel)]="selectedLocation" class="form-control" id="exampleFormControlSelect1">
          <option *ngFor='let location of locations' [value]='location.Locatie'>{{location.Locatie}}</option>
        </select>
      </div>
<button (click)="checkAvailability()" class="btn btn-primary">Check</button>

This is what happens when I click on said button:

checkAvailability()
  {
    this.res2 = {
      Datum: this.Datum,
      Locatie: this.selectedLocation
    }
    if(this.Datum != "")
    {
      this.Auth.checkAvailability(this.res2).subscribe(data =>
        {
          this.someint = data,
          this.anotherint = this.Capaciteit - this.someint,
          this.ruiid = this.RuimteId,
          {}
          if(this.anotherint > 0){ this.check = true}
        })
    }
    else( console.log("Choose a date!") )

  }

So basically when user chooses a date from the datepicker AND selects a location, the button connected to the checkAvailability() method executes the code inside it. What I want is for this to happen automatically, without the user having to click on the button.

So, I want the code in checkAvailability() to execute automatically every time the user chose a date AND a location.

By