gpt4 book ai didi

angular - 如何在 ng2-date-picker 中设置选项?

转载 作者:行者123 更新时间:2023-12-04 14:36:07 25 4
gpt4 key购买 nike

目前我正在使用 angular 2 日期选择器 ng2-date-picker。这里不知道怎么设置minDate、maxDate、dateFormat等选项。请帮我解决这个问题。

代码:

<dp-date-picker></dp-date-picker>

最佳答案

您可以在 component.ts 中创建一个配置对象,如下所示,

 constructor() {}
config = {
firstDayOfWeek: 'su',
monthFormat: 'MMM, YYYY',
disableKeypress: false,
allowMultiSelect: false,
closeOnSelect: undefined,
closeOnSelectDelay: 100,
onOpenDelay: 0,
weekDayFormat: 'ddd',
appendTo: document.body,
drops: 'down',
opens: 'right',
showNearMonthDays: true,
showWeekNumbers: false,
enableMonthSelector: true,
format: "YYYY-MM-DD HH:mm",
yearFormat: 'YYYY',
showGoToCurrent: true,
dayBtnFormat: 'DD',
monthBtnFormat: 'MMM',
hours12Format: 'hh',
hours24Format: 'HH',
meridiemFormat: 'A',
minutesFormat: 'mm',
minutesInterval: 1,
secondsFormat: 'ss',
secondsInterval: 1,
showSeconds: false,
showTwentyFourHours: true,
timeSeparator: ':',
multipleYearsNavigateBy: 10,
showMultipleYearsNavigation: false,
locale: 'zh-cn',
// min:'2017-08-29 15:50',
// minTime:'2017-08-29 15:50'
};

并在组件中称为,
 <dp-date-picker  theme="dp-material" [(ngModel)]="value" mode='daytime' [config]='config'
(ngModelChange)="validatorsChanged()"
[placeholder]="placeholder" [mode]='mode' #datePicker>
</dp-date-picker>

关于angular - 如何在 ng2-date-picker 中设置选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46752746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com