greatCodeIdeas / md-date-range-picker

Angular Material Date Range Picker Service/Directive
MIT License
62 stars 40 forks source link

Focus on same start and end date #45

Open orlandovallejos opened 6 years ago

orlandovallejos commented 6 years ago

I know this is a range picker, but I use it as a regular calendar because I prefer it over the Material Design option. Because of this, I set the start and end date with the same variable. Everything works fine, except when I want to see the date and see it focused.

This is what I guess it's causing this specific problem:

image

As in my case, both, start and end date are the same.

Is there any solution for this?

Any help would be appreciated! 😄

roelbarreto commented 6 years ago

Have you tried this one https://github.com/appfoundations/md-date-picker?

orlandovallejos commented 6 years ago

Thanks, but it's not what I need to use. This range calendar is great because of the combos with months and years. Besides I use this same component as a range picker in other modules of my app. It'd be very nice to use the same component along the whole app.

roelbarreto commented 6 years ago

Hi @orlandovallejos In your case, to compare the Date you need to convert them into string because The Dates might be different instance of an object. Example

var date1 = new Date();
var date2 = new Date();

console.log(date1 == date2); // false
console.log(date1.toLocaleDateString() == date2.toLocaleDateString()); // true
orlandovallejos commented 6 years ago

Thank you @ipiz but comparing dates is not my problem. I took that code from md-date-range-picker-js file.

All I want is to call the method focusToDate from mdDateRangePickerCtrl even though dates are the same, because that's what I'm using in this case. I'm using this control not as a range picker, BUT as a regular date picker. I really like it, that's why I want to use it as a regular date picker. Because of that, I set the startDate AND the endDate with the same variable, in my case $scope.myDate, for example.

This is how my HTML looks like: <md-date-range-picker date-start="vm.myDate" date-end="vm.myDate"></md-date-range-picker>

I hope I made clear what my problem is. Thanks for everything, this is an amazing component! 😄

Gautam19 commented 6 years ago

This is a versatile date range picker ,.I also have same requirement as above . I tried the datepicker ,however it wouldn't have a calendar view and DD/MM/YYYY format (which the Range Picker has) [ I basically need the DatePicker and Calendar View to be insync ].

I wanted to know how to limit the date selection to 1 day

Apologies if this issue has been addressed i went through commits and am going through again.

Thank You