简体   繁体   English

如何使用 Material Angular 设置多选日历?

[英]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.我在官方文档 ( https://material.angular.io/components/datepicker/overview ) 中没有看到任何内容,我被卡住了。

在此处输入图像描述

My code is that我的代码是

Ts: 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和 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.在 HTML 中,我可以设置范围选择器,但我不知道如何选择多个日期。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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