atularen / ngx-monaco-editor

Monaco Editor component for Angular 2 and Above
https://www.npmjs.com/package/ngx-monaco-editor
MIT License
428 stars 155 forks source link

Cannot use the library inside a standalone component #261

Closed shyam1992 closed 1 year ago

shyam1992 commented 1 year ago

I am trying to use the monaco editor in a standalone component and lazy load it to avoid the chunk size of my module. Hope this usecase makes sense. I get the usual Angular dependency injection error. Is there a way to solve it?

apps_configs_src_app_configuration-module_configuration_configuration_component_ts.js:2 ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(Standalone[ConfigurationComponent])[InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG]: NullInjectorError: No provider for InjectionToken NGX_MONACO_EDITOR_CONFIG! NullInjectorError: R3InjectorError(Standalone[ConfigurationComponent])[InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG]: NullInjectorError: No provider for InjectionToken NGX_MONACO_EDITOR_CONFIG! at NullInjector.get (core.mjs:6359:27) at R3Injector.get (core.mjs:6786:33) at R3Injector.get (core.mjs:6786:33) at R3Injector.get (core.mjs:6786:33) at R3Injector.get (core.mjs:6786:33) at R3Injector.get (core.mjs:6786:33) at ChainedInjector.get (core.mjs:13769:36) at lookupTokenUsingModuleInjector (core.mjs:3293:39) at getOrCreateInjectable (core.mjs:3338:12) at Module.ɵɵdirectiveInject (core.mjs:10871:12) at resolvePromise (zone.js:1211:31) at resolvePromise (zone.js:1165:17) at zone.js:1278:17 at _ZoneDelegate.invokeTask (zone.js:406:31) at Object.onInvokeTask (core.mjs:26218:33) at _ZoneDelegate.invokeTask (zone.js:405:60) at Zone.runTask (zone.js:178:47) at drainMicroTaskQueue (zone.js:585:35)

shyam1992 commented 1 year ago

It worked, I thought for standalone components, we don't need to import at the app level with forRoot()