fetrarij / ngx-daterangepicker-material

Pure Angular 2+ date range picker with material design theme, a demo here:
https://fetrarij.github.io/ngx-daterangepicker-material/
MIT License
249 stars 252 forks source link

Dynamic and Static date range problem #146

Open StudioTOB opened 5 years ago

StudioTOB commented 5 years ago

Hello,

First of all, thanks for this great date picker.

I currently have a issue with how we want to use this. The case is that we want to have dynamic and static dates. The dynamic part is working just fine. So, if a user clicks on the Last Month button, the value that is send to our API is last_month. This then makes the data dynamic because now it is May and the Last Month is April. Next month, this will then automatically shift the months by 1 month, making it dynamic.

The problem occurs when a user selects 2 dates on the calendar. If the start date is 01-04-2019 and the end date is 30-04-2019 then the datepicker detects that it is Last Month. This is a problem as it was not what the user expected.

Is there a way that we could use the daterange picker in this way, or maybe a workaround?

Thanks in advance,

Brian

Jorgen-VikingGod commented 5 years ago

You can handle this 'issue' inside your ts code. There are two events (rangeClicked) and (datesUpdated), so you can easily store data in your component and decide if it was a real range selection or a 'custom date' range.

fetrarij commented 5 years ago

Hi all, @Jorgen-VikingGod thank for the help. @StudioTOB does the solution provided by @Jorgen-VikingGod helps?

StudioTOB commented 5 years ago

Hi @fetrarij,

I've been trying his solution, but I could not get it working the way I want. If I find a solution, I will post it here.

fetrarij commented 5 years ago

@StudioTOB so, you want to know if the range selected is by the range list or by the date picker?

StudioTOB commented 5 years ago

@fetrarij Yes, that is basically what I need to make this work