Angular 5 material date picker

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Angular 5 material date picker



I need a functionality on Angular 5 date picker which provides option pick date based on daily, weekly, monthly, quarterly and yearly view. The following link is available for Angular 1.X versions.
https://material.angularjs.org/latest/demo/datepicker



I need a similar support for Angular 5. We have also explored the below option using jquery
enter code herehttp://jsfiddle.net/4mwk0d5L/1/ , but it would be better if the look and feel is like angular


enter code here





pretty sure angular material date picker (material.angular.io/components/datepicker/overview) has most of the functionality you describe, (check out Datepicker with filter validation). for selecting quarters I would write a component for that as it's more simple
– Shaniqwa
Apr 3 at 6:43





Hi @Shaniqwa, Thanks for your response, I found that date validation is helpful. However, In case of monthly view, quarterly or yearly view i need to display only the month and not the entire calendar with disabled dates. similarly for quarter as in jfidlle link shared. I will have a combo box for the user to select which type of report and based on that i can display the calendar. Please can you help me with montly , quarterly and yearly selection such that the dates are not available for the user to select.
– vijaya lakshmi
Apr 3 at 8:39







i am done with configuring for all the required reporting period. However i could not hide the date selection when the report for month to be selected
– vijaya lakshmi
Apr 3 at 10:46





Hi @Shaniqwa, Please can you help me on how to hide the date selection in date picker
– vijaya lakshmi
Apr 4 at 5:14




2 Answers
2



you can utilize this link..



This link has all types of date pickers you want ..
Click Here: https://embed.plnkr.co/nJyHfu/


You can use "ng2-daterangepicker".
Please refer below link
https://www.npmjs.com/package/ng2-daterangepicker
In the .html file, you can have following code

<div class="input-date-range-picker mx-3" daterangepicker [options]="{ opens: 'left' }"
(selected)="selectedDate($event, mainInput)">
<a> <i class="icon-calendar"></i>
{{ mainInput.start | date:'M/dd/y' }} - {{ mainInput.end| date:'M/dd/y' }}
</a>
</div>
(selected)="selectedDate($event, mainInput)" : will be the function call once you select the date.
mainInput : This is the default date selection parameter.

In .ts file add the following code.
import {DaterangePickerComponent, DaterangepickerConfig} from 'ng2-daterangepicker';

export class MyTestComponent implements OnInit {
mainInput = {
start: moment().subtract(1, 'month'),
end: moment()
};

constructor(private daterangepickerOptions: DaterangepickerConfig) {
this.daterangepickerOptions.settings = {
locale: {
format: 'YYYY-MM-DD'
},
alwaysShowCalendars: false,
ranges: {
'Last Month': [
moment().subtract(1, 'month'),
moment()
],
'Last 3 Months': [
moment().subtract(4, 'month'),
moment()
],
'Last 6 Months': [
moment().subtract(6, 'month'),
moment()
],
'Last 12 Months': [
moment().subtract(12, 'month'),
moment()
]
}
};



}
}






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results