简体   繁体   中英

How to set a multi select calendar with Material Angular?

I have a Calendar but i can only set one date and i want to be able to set multiple dates. I dont see anything in the official documentation ( https://material.angular.io/components/datepicker/overview ) and i´m stuck.

在此处输入图像描述

My code is that

Ts:

import {Component} from '@angular/core';

@Component({
  selector: 'datepicker-inline-calendar-example',
  templateUrl: 'datepicker-inline-calendar-example.html',
  styleUrls: ['datepicker-inline-calendar-example.css'],
})
export class DatepickerInlineCalendarExample {
  selected: Date | null;
}

And the HTML

<mat-card class="demo-inline-calendar-card">
  <mat-calendar [(selected)]="selected"></mat-calendar>
</mat-card>
<p>Selected date: {{selected}}</p>

In the HTML i can set range picker but i dont know how todo multiple select dates. Thanks

You have to use the Date range selection using, eg (like mentioned in the docs):

 <mat-date-range-input [rangePicker]="picker"> <input matStartDate placeholder="Start date"> <input matEndDate placeholder="End date"> </mat-date-range-input> <mat-date-range-picker #picker></mat-date-range-picker>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM