Last active
March 30, 2018 00:19
-
-
Save robwormald/f8aa584351be1648e21b2df496c533f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { createCustomElement } from '@angular/elements'; | |
import { NgModule, Injector, NgModuleFactory, NgModuleRef } from '@angular/core'; | |
import { SomeService } from './service' | |
import { AppComponent } from './app.component'; | |
import { DemoElementModule, DemoElement } from './demo-element' | |
import { DemoElementModuleNgFactory } from './demo-element.ngfactory' | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule | |
], | |
providers: [SomeService], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { | |
constructor(private injector:Injector){ | |
const elementsModuleInstance:NgModuleRef<DemoElementModule> = DemoElementModuleNgFactory.create(injector); | |
console.log(elementsModuleInstance); | |
const ElCtor = createCustomElement(DemoElement, {injector: elementsModuleInstance.injector }); | |
customElements.define('my-el', ElCtor); | |
} | |
ngDoBootstrap(){ | |
} | |
} |
This file contains hidden or 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 { createCustomElement } from '@angular/elements'; | |
import { NgModule, Injector, NgModuleFactory, NgModuleRef } from '@angular/core'; | |
import { SomeService } from './service' | |
import { AppComponent } from './app.component'; | |
import { DemoElementModule, DemoElement } from './demo-element' | |
import { DemoElementModuleNgFactory } from './demo-element.ngfactory' | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule | |
], | |
providers: [SomeService], | |
//bootstrap: [AppComponent] | |
}) | |
export class AppModule { | |
constructor(private injector:Injector){ | |
const elementsModuleInstance:NgModuleRef<DemoElementModule> = DemoElementModuleNgFactory.create(injector); | |
console.log(elementsModuleInstance); | |
const ElCtor = createCustomElement(DemoElement, {injector: elementsModuleInstance.injector }); | |
customElements.define('my-el', ElCtor); | |
} | |
ngDoBootstrap(applicationRef:ApplicationRef){ | |
applicationRef.bootstrap(SomeComponent) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment