Created
July 9, 2018 05:25
-
-
Save rahulsahay19/21c079627d5d1ac960fdb2df9018aeae to your computer and use it in GitHub Desktop.
app.module.ts
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 { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule, Injector } from '@angular/core'; | |
import { GreetComponent } from './greet/greet.component'; | |
import { createCustomElement } from '@angular/elements'; | |
@NgModule({ | |
declarations: [ | |
GreetComponent | |
], | |
imports: [ | |
BrowserModule | |
], | |
providers: [], | |
bootstrap: [], | |
entryComponents:[GreetComponent] | |
}) | |
export class AppModule { | |
constructor(private injector: Injector){ | |
//This method serves as a bridge which will convert angular component into custom element | |
//which can work with native DOM apis | |
const el = createCustomElement(GreetComponent, {injector: injector}); | |
//Final step is creating by custom element name and passing the element to that. | |
customElements.define('custom-greet', el); | |
} | |
ngDoBootstrap(){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment