A quick start project that helps you to create an Angular 6 DateRangePicker component with a minimal code configuration. Angular 6 DateRangePickerThe following section explains the steps required to create a simple Angular 6 DateRangePicker component. Pre-requisitesMake sure that you have the compatible versions of Angular in your machine before starting to work on this project.
IntroductionThe Angular 6 DateRangePicker used in this project is created from the Syncfusion ej2-angular-calendars package. You can simply define it as <ejs-daterangepicker> within the template. DependenciesBefore starting with this project, the Angular 6 DateRangePicker requires to add the Syncfusion ej2-angular-calendars package from npmjs, which are distributed in npm as @syncfusion scoped packages. Creating Angular ProjectTo create the Angular project using the Angular CLI tool, follow the given steps. Install Angular CLI 6 using following command.
Now, create a new Angular project by using the command ng new and navigate to that folder.
Install the ej2-angular-calendars package through the npm install command. Adding Angular 6 DateRangePickerYou can add the Angular 6 DateRangePicker component by using ejs-daterangepicker directive and the attributes within the tag allows you to define other functionalities. Import the DateRangePicker module into the Angular application (app.module.ts) from the ej2-angular-calendars package.
Define the Angular DateRangePicker code within the app.component.html file mapped against the templateUrl option in the app.component.ts file. Here, the DateRangePicker component is rendered using the startDate and endDate properties. [app.component.ts]
[app.component.html]
Refer to the CDN link of CSS reference within the index.html file. [index.html]
Run the application with the ng serve command, and the DateRangePicker will be displayed with start and end dates on the browser as shown below. Screenshot
Also, you can download and run the sample from this GitHub Repository. For more information about DateRangePicker functionalities, refer to UG Documentation, API Reference and Samples. |
This page will automatically be redirected to the sign-in page in 10 seconds.