The scenario i am working on is -> on selection of the date on mat datepicker i want to make a http call which performs a few calculations Trying to do this using (selectedChanged), but doesn't seem working, wanted help on how i could fix this, thanks in advance The below is the HTML code where i am trying to do this
<div class="form-group m-form__group row">
<div class="col-lg-4 m-form__group-sub">
<mat-form-field class="example-full-width" appearance="outline">
<mat-label>Policy Start Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate
[matDatepicker]="picker4"
placeholder="Choose a date" formControlName="policy_start_date" >
<mat-datepicker-toggle matSuffix [for]="picker4" >
</mat-datepicker-toggle>
<mat-datepicker #picker4 (selectedChanged)="currentPeriodClicked()">
</mat-datepicker>
</mat-form-field>
</div>
MatDatepicker does not have a selectedChanged event. Try using either the dateChange or dateInput event on MatDatepickerInput instead:
<mat-form-field class="example-full-width" appearance="outline">
<mat-label>Policy Start Date</mat-label>
<input matInput [min]="minDate" [max]="maxDate
[matDatepicker]="picker4"
(dateChange)="currentPeriodClicked()"
placeholder="Choose a date"
formControlName="policy_start_date" >
<mat-datepicker-toggle matSuffix [for]="picker4" ></mat-datepicker-toggle>
<mat-datepicker #picker4></mat-datepicker>
</mat-form-field>
See: https://v6.material.angular.io/components/datepicker/overview#input-and-change-events.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With