We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
6.0.0
组件示例
https://stackblitz.com/run?file=src%2Fapp%2Fapp.component.ts
import { Component, ViewEncapsulation } from '@angular/core';
@component({ selector: 'demo-date-picker-date', encapsulation: ViewEncapsulation.None, template: <List [className]="'date-picker-list'"> <ListItem DatePicker [extra]="currentDateFormat(value, 'yyyy-mm-dd')" [arrow]="'horizontal'" [mode]="'date'" [(ngModel)]="value" (onOk)="onOk($event)" > Date <Brief>{{ name }}</Brief> </ListItem> </List>, styles: [ .date-picker-list .am-list-item .am-list-line .am-list-extra { flex-basis: initial; } ] }) export class DemoDatePickerDateComponent { name = '选择'; value = new Date();
<List [className]="'date-picker-list'"> <ListItem DatePicker [extra]="currentDateFormat(value, 'yyyy-mm-dd')" [arrow]="'horizontal'" [mode]="'date'" [(ngModel)]="value" (onOk)="onOk($event)" > Date <Brief>{{ name }}</Brief> </ListItem> </List>
.date-picker-list .am-list-item .am-list-line .am-list-extra { flex-basis: initial; }
currentDateFormat(date, format: string = 'yyyy-mm-dd HH:MM'): any { const pad = (n: number): string => (n < 10 ? 0${n} : n.toString()); return format .replace('yyyy', date.getFullYear()) .replace('mm', pad(date.getMonth() 1)) .replace('dd', pad(date.getDate())) .replace('HH', pad(date.getHours())) .replace('MM', pad(date.getMinutes())) .replace('ss', pad(date.getSeconds())); }
0${n}
onOk(result: Date) { this.name = this.currentDateFormat(result, 'yyyy-mm-dd'); this.value = result; }
formatIt(date: Date, form: string) { const pad = (n: number) => (n < 10 ? 0${n} : n); const dateStr = ${date.getFullYear()}-${pad(date.getMonth() 1)}-${pad(date.getDate())}; const timeStr = ${pad(date.getHours())}:${pad(date.getMinutes())}; if (form === 'YYYY-MM-DD') { return dateStr; } if (form === 'HH:mm') { return timeStr; } return ${dateStr} ${timeStr}; } }
${date.getFullYear()}-${pad(date.getMonth() 1)}-${pad(date.getDate())}
${pad(date.getHours())}:${pad(date.getMinutes())}
${dateStr} ${timeStr}
选择了日期点击确定才赋值
还没点确定,关闭选择窗口已经赋值了
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Version
6.0.0
Environment
组件示例
Reproduction link
https://stackblitz.com/run?file=src%2Fapp%2Fapp.component.ts
Steps to reproduce
import { Component, ViewEncapsulation } from '@angular/core';
@component({
selector: 'demo-date-picker-date',
encapsulation: ViewEncapsulation.None,
template:
<List [className]="'date-picker-list'"> <ListItem DatePicker [extra]="currentDateFormat(value, 'yyyy-mm-dd')" [arrow]="'horizontal'" [mode]="'date'" [(ngModel)]="value" (onOk)="onOk($event)" > Date <Brief>{{ name }}</Brief> </ListItem> </List>
,styles: [
.date-picker-list .am-list-item .am-list-line .am-list-extra { flex-basis: initial; }
]
})
export class DemoDatePickerDateComponent {
name = '选择';
value = new Date();
currentDateFormat(date, format: string = 'yyyy-mm-dd HH:MM'): any {
const pad = (n: number): string => (n < 10 ?
0${n}
: n.toString());return format
.replace('yyyy', date.getFullYear())
.replace('mm', pad(date.getMonth() 1))
.replace('dd', pad(date.getDate()))
.replace('HH', pad(date.getHours()))
.replace('MM', pad(date.getMinutes()))
.replace('ss', pad(date.getSeconds()));
}
onOk(result: Date) {
this.name = this.currentDateFormat(result, 'yyyy-mm-dd');
this.value = result;
}
formatIt(date: Date, form: string) {
const pad = (n: number) => (n < 10 ?
0${n}
: n);const dateStr =
${date.getFullYear()}-${pad(date.getMonth() 1)}-${pad(date.getDate())}
;const timeStr =
${pad(date.getHours())}:${pad(date.getMinutes())}
;if (form === 'YYYY-MM-DD') {
return dateStr;
}
if (form === 'HH:mm') {
return timeStr;
}
return
${dateStr} ${timeStr}
;}
}
What is expected?
选择了日期点击确定才赋值
What is actually happening?
还没点确定,关闭选择窗口已经赋值了
Other?
The text was updated successfully, but these errors were encountered: