Skip to content

Instantly share code, notes, and snippets.

@robwormald
Last active March 30, 2018 00:19
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 robwormald/f8aa584351be1648e21b2df496c533f8 to your computer and use it in GitHub Desktop.
Save robwormald/f8aa584351be1648e21b2df496c533f8 to your computer and use it in GitHub Desktop.
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(){
}
}
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