Date views in Angular Datepicker component
27 Apr 20243 minutes to read
The DatePicker has the following predefined views that provides a flexible way to navigate back and forth to select the date.
View | Description |
---|---|
month(default) | Displays the days in a month |
year | Displays the months in a year |
decade | Displays the years in a decade |
Start view
You can use the start
property to define the initial rendering view.
The following example demonstrates how to create a DatePicker with decade
as initial rendering view.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { DatePickerModule } from '@syncfusion/ej2-angular-calendars'
import { Component } from '@angular/core';
@Component({
imports: [
DatePickerModule
],
standalone: true,
selector: 'app-root',
template: `<ejs-datepicker start='Decade' placeholder='Enter date'></ejs-datepicker>`
})
export class AppComponent {
constructor() {
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Depth view restriction
Define the depth
property to control the view navigation.
Always the depth view has to be smaller than the start view, otherwise the view restriction will be not restricted.
The following example demonstrates how to create a DatePicker that allows users to select a month.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { DatePickerModule } from '@syncfusion/ej2-angular-calendars'
import { Component } from '@angular/core';
@Component({
imports: [
DatePickerModule
],
standalone: true,
selector: 'app-root',
template: `<ejs-datepicker start='Decade' depth='Year' placeholder='Enter date'></ejs-datepicker>`
})
export class AppComponent {
constructor() {
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
To know more about Calendar views refer the Calendar’s Calendar Views section.