【发布时间】:2020-02-12 23:05:49
【问题描述】:
我在 Angular 中使用 Formly 和 Material 并且有一个日期选择器。我想要做的就是禁用未来的日期,因此在选择日期时无法选择它们,我似乎无法在网上找到任何东西!
export class AppComponent {
form = new FormGroup({});
model: any = {};
options: FormlyFormOptions = {};
fields: FormlyFieldConfig[] = [
{
key: 'Datepicker',
type: 'datepicker',
templateOptions: {
label: 'Datepicker',
placeholder: 'Placeholder',
description: 'Description',
required: true,
//what to put here to disable future dates?
},
},
];
}
您可以在此处使用代码: https://stackblitz.com/angular/gkyxqxygybo?file=src%2Fapp%2Fapp.component.ts
【问题讨论】:
-
我发现 here 可以使用
maxDate但是当我在上面声明表单的地方添加date = new Date();然后maxDate: this.date 时,它什么也没做跨度>
标签: angular datepicker angular-material angular-formly