Loading...
Loading...
Compare original and translation side by side
import { Component } from '@angular/core';
import { DatePickerModule } from '@syncfusion/ej2-angular-calendars';
@Component({
selector: 'app-datepicker-demo',
standalone: true,
imports: [DatePickerModule],
template: `
<ejs-datepicker
placeholder="Select date"
[(ngModel)]="selectedDate"
(change)="onDateChange($event)">
</ejs-datepicker>
<p>Selected: {{ selectedDate | date:'fullDate' }}</p>
`
})
export class DatePickerDemoComponent {
selectedDate: Date | null = null;
onDateChange(event: any) {
console.log('Date changed:', event.value);
}
}@syncfusion/ej2-angular-calendarsDatePickerModule<ejs-datepicker>[(ngModel)]import { Component } from '@angular/core';
import { DatePickerModule } from '@syncfusion/ej2-angular-calendars';
@Component({
selector: 'app-datepicker-demo',
standalone: true,
imports: [DatePickerModule],
template: `
<ejs-datepicker
placeholder="Select date"
[(ngModel)]="selectedDate"
(change)="onDateChange($event)">
</ejs-datepicker>
<p>Selected: {{ selectedDate | date:'fullDate' }}</p>
`
})
export class DatePickerDemoComponent {
selectedDate: Date | null = null;
onDateChange(event: any) {
console.log('Date changed:', event.value);
}
}@syncfusion/ej2-angular-calendarsDatePickerModule<ejs-datepicker>[(ngModel)]minDate = new Date(2024, 0, 1); // Jan 1, 2024
maxDate = new Date(2024, 11, 31); // Dec 31, 2024<ejs-datepicker
[min]="minDate"
[max]="maxDate"
placeholder="Select date in 2024">
</ejs-datepicker>minDate = new Date(2024, 0, 1); // 2024年1月1日
maxDate = new Date(2024, 11, 31); // 2024年12月31日<ejs-datepicker
[min]="minDate"
[max]="maxDate"
placeholder="Select date in 2024">
</ejs-datepicker>dateFormat = 'dd/MM/yyyy'; // European format<ejs-datepicker
[format]="dateFormat"
placeholder="DD/MM/YYYY">
</ejs-datepicker>dateFormat = 'dd/MM/yyyy'; // 欧洲格式<ejs-datepicker
[format]="dateFormat"
placeholder="DD/MM/YYYY">
</ejs-datepicker><ejs-datepicker
[enableMask]="true"
[maskPlaceholder]="'day'"
format="dd/MM/yyyy">
</ejs-datepicker><ejs-datepicker
[enableMask]="true"
[maskPlaceholder]="'day'"
format="dd/MM/yyyy">
</ejs-datepicker>minDate = new Date(); // Today
maxDate: Date;
constructor() {
// Set max to 90 days from today
this.maxDate = new Date();
this.maxDate.setDate(this.maxDate.getDate() + 90);
}minDate = new Date(); // 今日
maxDate: Date;
constructor() {
// 最大可选日期为今日起90天内
this.maxDate = new Date();
this.maxDate.setDate(this.maxDate.getDate() + 90);
}import { ReactiveFormsModule, FormBuilder, Validators } from '@angular/forms';
export class FormComponent {
form = this.fb.group({
birthDate: [null, [Validators.required]],
});
constructor(private fb: FormBuilder) {}
}<form [formGroup]="form">
<ejs-datepicker
formControlName="birthDate"
placeholder="Birth date">
</ejs-datepicker>
<span *ngIf="form.get('birthDate')?.hasError('required')">
Birth date is required
</span>
</form>import { ReactiveFormsModule, FormBuilder, Validators } from '@angular/forms';
export class FormComponent {
form = this.fb.group({
birthDate: [null, [Validators.required]],
});
constructor(private fb: FormBuilder) {}
}<form [formGroup]="form">
<ejs-datepicker
formControlName="birthDate"
placeholder="Birth date">
</ejs-datepicker>
<span *ngIf="form.get('birthDate')?.hasError('required')">
Birth date is required
</span>
</form>| Property | Type | Notes |
|---|---|---|
| boolean | Whether textbox is editable (defaults true) |
| CalendarType | Calendar type (e.g., Gregorian, Islamic) |
| string | Root CSS class for custom styling |
| DayHeaderFormats | Day header format (Short/Narrow/Abbreviated/Wide) |
| CalendarView | Deepest allowed calendar view (Month/Year/Decade) |
| boolean | Enable masked date input |
| boolean | Persist component state between reloads |
| boolean | Enable right-to-left rendering |
| boolean | Enable or disable the component (set |
| number | First day of week (0-6) |
| FloatLabelType | string |
| string|FormatObject | Display format for the value |
| boolean | Popup full-screen mode on mobile |
| { [key:string]: string } | Additional HTML attributes for root element |
| string[]|FormatObject[] | Acceptable input formats for parsing |
| { [key:string]: string } | Custom key action mappings |
| string | Override global culture (e.g., 'en-US') |
| MaskPlaceholderModel | Placeholder text for masked input |
| Date | Maximum selectable date |
| Date | Minimum selectable date |
| boolean | Open popup on input focus |
| string | Input placeholder text |
| boolean | Make input readonly (no typing) |
| number | Server timezone offset in minutes (optional) |
| boolean | Show/hide clear icon |
| boolean | Show/hide today button in popup |
| CalendarView | Initial view when popup opens |
| boolean | Enforce strict parsing/validation |
| Date | Selected date value |
| boolean | Show week numbers in calendar |
| WeekRule | Rule for first week of year |
| number|string | Component width |
| number | Z-index for popup |
| 属性 | 类型 | 说明 |
|---|---|---|
| boolean | 文本框是否可编辑(默认true) |
| CalendarType | 日历类型(如公历、伊斯兰历) |
| string | 用于自定义样式的根CSS类 |
| DayHeaderFormats | 日期头部格式(短/窄/缩写/全写) |
| CalendarView | 允许的最深日历视图(月/年/十年) |
| boolean | 启用日期输入掩码 |
| boolean | 重载页面时保留组件状态 |
| boolean | 启用从右到左渲染 |
| boolean | 启用或禁用组件(设为 |
| number | 一周的首日(0-6) |
| FloatLabelType | string |
| string|FormatObject | 值的展示格式 |
| boolean | 移动端弹出层全屏模式 |
| { [key:string]: string } | 根元素的额外HTML属性 |
| string[]|FormatObject[] | 可识别的输入解析格式 |
| { [key:string]: string } | 自定义按键操作映射 |
| string | 覆盖全局文化配置(如'en-US') |
| MaskPlaceholderModel | 掩码输入的占位文本 |
| Date | 最大可选日期 |
| Date | 最小可选日期 |
| boolean | 输入框获焦时打开弹出层 |
| string | 输入框占位文本 |
| boolean | 设置输入框为只读(不可输入) |
| number | 服务器时区偏移(分钟,可选) |
| boolean | 显示/隐藏清空图标 |
| boolean | 弹出层中显示/隐藏今日按钮 |
| CalendarView | 弹出层打开时的初始视图 |
| boolean | 启用严格解析/校验 |
| Date | 选中的日期值 |
| boolean | 日历中显示周数 |
| WeekRule | 新年第一周的计算规则 |
| number|string | 组件宽度 |
| number | 弹出层的z-index |
currentView()destroy()focusIn()focusOut()getPersistData()hide()navigateTo(view: CalendarView, date?: Date)removeDate(dates: Date|Date[])show()currentView()destroy()focusIn()focusOut()getPersistData()hide()navigateTo(view: CalendarView, date?: Date)removeDate(dates: Date|Date[])show()blurchangeChangedEventArgsclearedclosecreateddestroyedfocusnavigatedopenrenderDayCellblurchangeChangedEventArgsclearedclosecreateddestroyedfocusnavigatedopenrenderDayCell