technikhil314 / angular-components

Collection of all my open source angular components
https://github.com/technikhil314/angular-components
MIT License
24 stars 30 forks source link

bug report: cant import component #49

Closed vithano closed 3 years ago

vithano commented 3 years ago

hi im trying to import the daterangepicker component and im getting this error: image

im importing like this: import { DaterangepickerComponent } from 'angular-datetimerangepicker/daterangepicker/daterangepicker.component'; and i do have the module in my app.module.ts

technikhil314 commented 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

vithano commented 3 years ago

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 image 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

image

technikhil314 commented 3 years ago

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

vithano commented 3 years ago

things ive tried: image this didn't work, had no effect on values image this worked only if i added setRange, without it the changes werent propagating to the value of the input with: image without: image

technikhil314 commented 3 years ago

Ok got your use case now. I will release new version for this.

technikhil314 commented 3 years ago

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

vithano commented 3 years ago

works well now ,thanks for the quick fixes