material-spirit / ngx-split-button

Split Button for Angular Material.
https://split-button.material-spirit.dev
MIT License
2 stars 0 forks source link

NG05100: Providers from the `BrowserModule` have already been loaded #1

Closed GipHub123 closed 1 year ago

GipHub123 commented 1 year ago

This component was exactly that I was looking for . Nice work 😃

MasSplitButtonModule contains for some reason BrowsersModule . In real application BrowsersModule is most likely already imported. If that's the case it leads to the following error.

ERROR Error: Uncaught (in promise): Error: NG05100: Providers from the `BrowserModule` have already been loaded. If you need access to common directives such as NgIf and NgFor, import the `CommonModule` instead.
Error: NG05100: Providers from the `BrowserModule` have already been loaded. If you need access to common directives such as NgIf and NgFor, import the `CommonModule` instead.
    at new BrowserModule (platform-browser.mjs:1145:19)
    at Object.BrowserModule_Factory [as useFactory] (platform-browser.mjs:1167:23)
    at Object.factory (core.mjs:9369:38)
    at R3Injector.hydrate (core.mjs:9276:35)
    at R3Injector.get (core.mjs:9164:33)
    at injectInjectorOnly (core.mjs:651:33)
    at ɵɵinject (core.mjs:655:60)
    at useValue (core.mjs:8950:65)
    at R3Injector.resolveInjectorInitializers (core.mjs:9213:17)
    at new EnvironmentNgModuleRefAdapter (core.mjs:21629:22)
    at resolvePromise (zone.js:1193:31)
    at resolvePromise (zone.js:1147:17)
    at zone.js:1260:17
    at _ZoneDelegate.invokeTask (zone.js:402:31)
    at core.mjs:25881:55
    at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:25881:36)
    at _ZoneDelegate.invokeTask (zone.js:401:60)
    at Object.onInvokeTask (core.mjs:26182:33)
    at _ZoneDelegate.invokeTask (zone.js:401:60)
    at Zone.runTask (zone.js:171:47)

Library uses angular ~v15 so I would update component to standalone. This way you could remove that unnecessary module.

klyakh commented 1 year ago

Congratulations! You are the first user of this library :blush:

Probably the problem with BrowserModule appears only if the library is used in lazy-loaded module. Thanks for reporting it.

I've replaced BrowserModule with CommonModule and released a new version - 1.0.1

GipHub123 commented 1 year ago

Already fixed 👍 I'm sure that there are others as well 😜