Created
March 21, 2020 14:17
-
-
Save eliraneliassy/b7bd9e8bc53023d3f0da530585b7a628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { enableProdMode, NgModuleRef } from '@angular/core'; | |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | |
import { AppModule } from './app/app.module'; | |
import { environment } from './environments/environment'; | |
import { createCustomElement } from '@angular/elements'; | |
import { MyElementComponent } from 'my-element'; | |
if (environment.production) { | |
enableProdMode(); | |
} | |
platformBrowserDynamic().bootstrapModule(AppModule).then((ref: NgModuleRef<AppModule>) => { | |
const myElement = createCustomElement(MyElementComponent, { | |
injector: ref.injector | |
}); | |
customElements.define('my-element', myElement as any); | |
}) | |
.catch(err => console.error(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment