Closed vithano closed 3 years ago
Hey you should not import component. But you should import daterangepicker module instead.
Check this example here https://stackblitz.com/edit/angular-datetimerangepicker-demo-without-bootstrap
Also check the https://technikhil314.netlify.app/docs/daterangepicker/how-to-use
You just need to add two lines to your app.module.ts
and then start using the component
here is what im trying to do , when changing the date from a different source, in my case buttons that move the selected time frame to next week/previous week and today i want this to be reflected on the date picker(you can see the picture in the previous request i made) im referencing your component as #datepicker then im changing the date on it dynamically like this, i cant use the actual component because of that error and i m forced to use "any" instead
Probably you are using it in wrong way. You simply need to change the options object in viewDateChange
function. And it should work. Cause daterangepicker
component handles ngOnChanges
event already. Check the stackblitz example. See how the options change dynamically in that example. What you are doing is hacky way.
And if this does not work
Use setToDate
and setFromDate
functions instead of setRange
things ive tried: this didn't work, had no effect on values this worked only if i added setRange, without it the changes werent propagating to the value of the input with: without:
Ok got your use case now. I will release new version for this.
Please use v2.3.1
You simply need to pass new options object from your viewDateChange
function. something like
viewDateChange(date: Date) {
this.daterangepickerOptions = {
...this.daterangepickerOptions,
startDate: Dayjs(date).startOf('day'),
endDate: Dayjs(date).add(7, 'day').endOf('day')
}
}
This should work now need of calling setRange
etc.
Check this example for more details
https://stackblitz.com/edit/angular-datetimerangepicker-update-dates-demo
Click on the change dates
button and the dates will change
works well now ,thanks for the quick fixes
hi im trying to import the daterangepicker component and im getting this error:
im importing like this: import { DaterangepickerComponent } from 'angular-datetimerangepicker/daterangepicker/daterangepicker.component'; and i do have the module in my app.module.ts