Articles in this section
Category / Section

How to Bind Current Date to Angular DatePicker?

1 min read

Binding the current date to a DatePicker is a common requirement in Angular applications. This guide demonstrates how to achieve this using Angular and the Syncfusion® Angular DatePicker component.


Prerequisites

Implementation

The value property of the Syncfusion® Angular DatePicker enables binding the current system date using JavaScript’s new Date() constructor.

app.component.html
<ejs-datepicker [value]="currentDate" placeholder="Select a date"></ejs-datepicker>
app.component.ts
import { DatePickerModule } from '@syncfusion/ej2-angular-calendars';

@Component({
  selector: 'app-root',
  styleUrls: ['app.component.css'],
  templateUrl: 'app.component.html',
  encapsulation: ViewEncapsulation.None,
  standalone: true,
  imports: [DatePickerModule],
})
export class AppComponent {
  public currentDate: Date = new Date(); // Binds today's date
}

Key Points

  • The value property accepts a Date object for date binding
  • Using new Date() automatically sets the current system date

Preview

Bind Current Date to Angular DatePicke

The DatePicker component will display with the current date pre-selected, providing users with immediate context while allowing them to modify the selection as needed.

Additional Resources

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied