11import { ApplicationRef , DoBootstrap , Injector , NgModule } from '@angular/core' ;
22import { BrowserModule } from "@angular/platform-browser" ;
3- import { ToggleComponent } from "./toggle.component" ;
43import { createCustomElement } from "@angular/elements" ;
4+ import { WorldMapComponent } from "./map/world-map/world-map.component" ;
5+ import { MapsModule } from "./map/maps.module" ;
6+ import { LegendMapComponent } from "./map/legend-map/legend-map.component" ;
57
68@NgModule ( {
79 imports : [
810 BrowserModule ,
9- ToggleComponent
11+ MapsModule
1012 ] ,
1113 providers : [ ] ,
1214} )
@@ -17,16 +19,27 @@ export class ElementModule implements DoBootstrap {
1719 ) { }
1820
1921 ngDoBootstrap ( appRef : ApplicationRef ) {
20- if ( ! customElements . get ( 'login-provider ' ) ) {
22+ if ( ! customElements . get ( 'world-map ' ) ) {
2123 // Register only if 'login-provider' entry is not found in the registry
2224
2325 // Step 3: loginComponent stores the constructor class
24- const loginComponent = createCustomElement ( ToggleComponent , {
26+ const worldComponent = createCustomElement ( WorldMapComponent , {
2527 injector : this . injector , // This injector is used to load the component's factory
2628 } ) ;
2729
2830 // Step 4: Registering custom tag 'login-provider' with the obtained custom class
29- customElements . define ( 'login-provider' , loginComponent ) ;
31+ customElements . define ( 'world-map' , worldComponent ) ;
32+ }
33+ if ( ! customElements . get ( 'world-legend-map' ) ) {
34+ // Register only if 'login-provider' entry is not found in the registry
35+
36+ // Step 3: loginComponent stores the constructor class
37+ const worldLegendComponent = createCustomElement ( LegendMapComponent , {
38+ injector : this . injector , // This injector is used to load the component's factory
39+ } ) ;
40+
41+ // Step 4: Registering custom tag 'login-provider' with the obtained custom class
42+ customElements . define ( 'world-legend-map' , worldLegendComponent ) ;
3043 }
3144 }
3245}
0 commit comments