Angular: Material Datepicker: date range selection in month view

Discussão em 'Angular' iniciado por TheCuBeMan, Dezembro 2, 2024.

  1. TheCuBeMan

    TheCuBeMan Guest

    I am working with Angular/Material version 19 (standalone).

    When I want to display the calendar in a month view, this is my template's code:

    <mat-calendar #calendar
    [(selected)]="selected"
    [dateClass]="dateClass"
    (selectedChange)="onDateSelected($event)">
    </mat-calendar>


    [​IMG]

    And everything is working fine.

    When I want to display the calendar for date range selection, this is the template code:

    <mat-form-field>
    <mat-label>Select a date range</mat-label>
    <mat-date-range-input [formGroup]="range" [rangePicker]="picker">
    <input matStartDate formControlName="start" placeholder="Start date" readonly />
    <input matEndDate formControlName="end" placeholder="End date" readonly />
    </mat-date-range-input>
    <mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
    <mat-date-range-picker #picker></mat-date-range-picker>
    </mat-form-field>


    [​IMG]

    And everything is working fine with that too.

    But now, I need them combined - I need to show the calendar in a month view, but for the user to select a date range and not just a single specific date.

    How do I do that exactly? If that's possible, of course.

    Continue reading...

Compartilhe esta Página