Skip to content

Instantly share code, notes, and snippets.

@sulco
Created April 30, 2018 20:57
Show Gist options
  • Save sulco/0c671e5604095b1ad2b1410593fac6e7 to your computer and use it in GitHub Desktop.
Save sulco/0c671e5604095b1ad2b1410593fac6e7 to your computer and use it in GitHub Desktop.
Sample module that defines an Angular custom element
import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { createCustomElement } from '@angular/elements';
import { ButtonComponent } from './button.component';
@NgModule({
imports: [BrowserModule],
declarations: [ButtonComponent],
entryComponents: [ButtonComponent]
})
export class ButtonModule {
constructor(private injector: Injector) {
const customButton = createCustomElement(ButtonComponent, { injector });
customElements.define('custom-button', customButton);
}
ngDoBootstrap() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment