evansmwendwa / ng2-daterangepicker

Usage Demos update in this url >>>
https://codesandbox.io/s/6yr1zm18w3
MIT License
132 stars 88 forks source link

Failing to register Module when using angular 9 (Ivy) #126

Closed eni9889 closed 4 years ago

eni9889 commented 4 years ago

Got this when updated to Angular 9. The issue seems to be with the date range picker module. Anyone else experience this and or have a possible solution?

image

agrinko commented 4 years ago

I also have an error during ng build with --prod flag:

node_modules/ng2-daterangepicker/lib/daterangepicker/daterangepicker.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of AdminModule, but could not be resolved to an NgModule class

1 export declare class Daterangepicker {

evansmwendwa commented 4 years ago

I am in the process of upgrading the package to angular 9 and the latest version of daterangepicker. Should have a testable version in the next couple of days

https://github.com/evansmwendwa/ng2-daterangepicker/commit/11bdc18aa5c1879375719d8f7cfb0eab16bac461

eni9889 commented 4 years ago

@evansmwendwa sorry to be a bother but is there an ETA or is there anything I can help with?

evansmwendwa commented 4 years ago

@eni9889 a beta release is available. Kindly test and share feedback

npm install ng2-daterangepicker@3.0.0-beta.1

Refer to the link below for setup instructions and add a comment if you encounter any challenges.

https://github.com/evansmwendwa/ng2-daterangepicker/blob/ng9-support/README.md

agrinko commented 4 years ago

@evansmwendwa , thanks for the efforts. But it doesn't seem to work. I get this error in console when trying to render daterange picker component which worked in previous versions:

core.js:5845 ERROR Error: Cannot find a differ supporting object 'undefined'
    at KeyValueDiffers.find (core.js:29607) [angular]
    at new DaterangepickerComponent (ng2-daterangepicker.js:30) [angular]
    at NodeInjectorFactory.DaterangepickerComponent_Factory [as factory] (ng2-daterangepicker.js:106) [angular]
    at getNodeInjectable (core.js:5615) [angular]
    at instantiateAllDirectives (core.js:12662) [angular]
    at createDirectivesInstances (core.js:11898) [angular]
    at ɵɵelementStart (core.js:20961) [angular]
    at DaterangeComponent_Template (template.html:1) [angular]

It happens in the DaterangepickerComponent constructor, on its last line. Ivy pre-compiles the component file using ngcc tool, and the error happens on this line in webpack:////home/user/my-project/node_modules/ng2-daterangepicker/__ivy_ngcc__/fesm2015/ng2-daterangepicker.js: this._differ['settings'] = this.differs.find(this.config.settings).create();

And then there's also this weird error:

core.js:5845 ERROR Error: ASSERTION ERROR: Reached the max number of directives [Expected=> 5 != 5 <=Actual]

Is anybody getting the same?

evansmwendwa commented 4 years ago

@agrinko can you try the latest beta and let me know if it fixes that issue

npm install ng2-daterangepicker@3.0.0-beta.2
agrinko commented 4 years ago

@evansmwendwa now it actually works, no errors in console. But it doesn't have styles, perhaps I did something wrong. In your readme you mention that I need to attach "daterangepicker.css" file to the styles array in angular.json, but where do I get that file? I don't see any CSS files in node_modules/ng2-daterangepicker, where do I get it from? And how did it work before, in previous versions? I didn't include any special styles in angular.json for daterangepicker, I guess

evansmwendwa commented 4 years ago

I have updated the documentation and packaged the relevant stylesheet that needs to be imported under styles in angular.json

Kindly refer to the latest release and updated documentation.

The latest version has also been released without a beta tag but backwards compatibility is not guaranteed. The docs should have all the necessary steps.

npm install ng2-daterangepicker
agrinko commented 4 years ago

Thank you @evansmwendwa , it is working now! We can close the issue