Jey*_*ani 2 typescript angular
目前我正在使用 angular 2 日期选择器 ng2-date-picker。这里不知道怎么设置minDate、maxDate、dateFormat等选项。请帮我解决这个问题。
代码:
<dp-date-picker></dp-date-picker>
Run Code Online (Sandbox Code Playgroud)
您可以在 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'
};
Run Code Online (Sandbox Code Playgroud)
并在组件中引用为,
<dp-date-picker theme="dp-material" [(ngModel)]="value" mode='daytime' [config]='config'
(ngModelChange)="validatorsChanged()"
[placeholder]="placeholder" [mode]='mode' #datePicker>
</dp-date-picker>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8876 次 |
最近记录: |