Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created July 9, 2018 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsahay19/21c079627d5d1ac960fdb2df9018aeae to your computer and use it in GitHub Desktop.
Save rahulsahay19/21c079627d5d1ac960fdb2df9018aeae to your computer and use it in GitHub Desktop.
app.module.ts
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