ng-matero / extensions

Angular Material Extensions Library.
https://ng-matero.github.io/extensions/
MIT License
393 stars 48 forks source link

Error when using Datetimepicker provided in a library #241

Closed SYS64738 closed 9 months ago

SYS64738 commented 9 months ago

Hi, I used Datetimepicker in a projects deployed as a library; when I run app directly in library projects all works fine; when I build the library and try to use my component (that contains a Datetimepicker) a strange error occurs.

image

image

image

image

If I use standard Material mat-datepicker instead of mtx-datetimepicker, without changing anything else, all works fine...

Thank you very much for any suggestion and have a nice day

nzbin commented 9 months ago

I'm not sure what the reason and I hope you can give me on online example.

SYS64738 commented 9 months ago

for sure I can provide you what you need. It's not so easy to provide current project, the library contains a very big form, with many sections.

I'll try to arrange a little application, then I'll inform you.

thank you

SYS64738 commented 9 months ago

preparing an example for you, I made a deep check: I start to build an empty app that used only my lib with Datetimepicker, and it works fine.

then I start adding, one by one, remaining high level deps, until I find that one of our custom lib, when added as deps to main app, would cause the error.

in fact, that library would importing MatNativeDateModule instead of MatMomentDateModule (even if doesn't use dates at all); moving the import to MatMomentDateModule has resolved the issue.

resuming, I was start in this situation:

my_custom_lib_1 (with Datetimepicker) -> import MatMomentDateModule my_custom_lib_2 (without Datetimepicker) -> import MatMomentDateModule my_custom_lib_3 (without Datetimepicker and dates at all) -> Import MatNativeDateModule

my_main_app -> import lib_1, lib_2, lib_3 and MatMomentDateModule -> ERROR!

removing MatNativeDateModule deps and adding MatMomentDateModule (since I use the same Material module set everywhere), all works fine... I forgot to migrate some times ago that library to Moment...

sorry for wasting time, I hope this could be useful for other people...

have a nice weekend!