qwerty
qwerty

Reputation: 23

get selected day value before using mat-date-range-picker-actions

I have a date range picker. How can I get the selected day before closing the calendar. I tried dateInput, dateChanges, but if I have mat-date-range-picker-actions in my code, I only get the value after apply it. Any solutions to get the value right after the click

<mat-form-field appearance="fill">
    <mat-label>MAT-LABEL</mat-label>
    <mat-date-range-input
      [rangePicker]="rangePicker">
      <input
        matStartDate/>
      <input
        matEndDate />
    </mat-date-range-input>
    <mat-datepicker-toggle matSuffix [for]="rangePicker"></mat-datepicker-toggle>
    <mat-date-range-picker #rangePicker>
      <mat-date-range-picker-actions>

          <div>
            <button mat-stroked-button color="primary" matDateRangePickerCancel>{{
              cancel
            }}</button>
            <button mat-flat-button color="primary" matDateRangePickerApply>{{
             apply
            }}</button>
          </div>
        </div>
      </mat-date-range-picker-actions>
    </mat-date-range-picker>
  </mat-form-field>

i tried dateInput, dateChanges. Works, without mat-date-range-picker-actions, but i need that part of the code

Upvotes: 1

Views: 447

Answers (1)

Tasos Kakouris
Tasos Kakouris

Reputation: 175

You missing the model property.

You need to add an ngmodel directive or a formcontrol. Check this example

https://material.angular.io/components/datepicker/overview#date-range-picker-forms

Upvotes: -1

Related Questions