angular2-image-gallery icon indicating copy to clipboard operation
angular2-image-gallery copied to clipboard

Issue lazy loading module

Open rustygreen opened this issue 6 years ago • 3 comments

This library does not work when trying to use it in lazy-loaded modules, due to the fact that the library imports "BrowserAnimationsModule". An angular library should not import this module.

This library (with the current module imports) cannot be used in lazily-loaded modules and cannot be used with server-side render (Angular Universal). I suggest removing the "BrowserAnimationsModule" import. Also, I see the "FormsModule" being imported, but I did not see it being used? Perhaps the "FormsModule" import can be removed too? Would you accept a PR if I made this change?

I'm suggesting changing:

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    HttpClientModule,
    BrowserAnimationsModule
  ],

To:

@NgModule({
  imports: [
    CommonModule,
    HttpClientModule
  ],

This may be related to issue #32 but I couldn't find a PR for the issue.

Let me know your thoughts.

Thanks,

rustygreen avatar Jul 07 '19 19:07 rustygreen

Yes, would love to merge a PR on this topic.

Please do me a favor and test the integration in default projects without lazy loading before submitting the PR. I will do so as well when I find some time but this will save roundtrips.

BenjaminBrandmeier avatar Jul 10 '19 07:07 BenjaminBrandmeier

yes! i agree with @rustygreen. How can i remove BrowserAnimationsModule?

mayrong avatar Aug 25 '19 00:08 mayrong

I have similar error when uses it on lazy loaded module

Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.

MarcFarres avatar Feb 11 '20 23:02 MarcFarres

This should be fixed with the new 14 release.

BenjaminBrandmeier avatar Sep 12 '22 19:09 BenjaminBrandmeier