Tutorialsplane

Angular Material Datepicker


Angular Material Datepicker(Calender) : <md-datepicker> directive is used to create a datepicker. Here in this tutorials we are going to explain how to use <md-datepicker> directive to create datepicker. You can use our online editor to edit and run the code online.


How to Create Angular Material Datepicker ? Calender

Let us go step by step to create Angular Material Datepicker.

<md-datepicker> Component supports AngularJs ngMessages Directive. Attributes supported are –

Example

Now let us create very basic example using <md-datepicker> directive.

Angular Material Datepicker | Example:

<md-datepicker ng-model="birthDate"></md-datepicker>
Try It On →

If you run the above example it will produce output something like this –

Options Available

Following options are available you can use them as per your requirement.


Learn More | Customized Datepicker Examples

Let us have some example and demo about the Angular Material Calender.


Disabled Datepicker

You can create disabled datepicker using the attribute ng-disabled. Here is an example.

Disabled Datepicker/Calender| Example:

<md-datepicker ng-disabled="true" ng-model="birthDate"></md-datepicker>

Try it »

Enable Datepicker

To enable the datepicker just set ng-disabled=”false”.

Set Minimum and Maximum | Range in Datepicker

If you want to set the minimum and maximum date selection criteria you can use md-min-date and md-max-date attribute. Here is an example.

Min and Max Datepicker/Calender| Example:

<md-datepicker md-min-date="minDate" md-max-date="maxDate" ng-model="birthday"></md-datepicker>

Try it »

Where minDate and maxDate are date objects declared in controller.

If you run the above example it will produce output something like this. Only the months within the provided date will be enabled other will be disabled –

Learn Angular Material