2018-02-27 13:33:41 -08:00
|
|
|
import { Component, Injector } from '@angular/core';
|
2018-07-11 16:34:56 +02:00
|
|
|
import { createCustomElement } from '@angular/elements';
|
2018-02-27 13:33:41 -08:00
|
|
|
import { PopupService } from './popup.service';
|
|
|
|
|
import { PopupComponent } from './popup.component';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
|
|
|
|
template: `
|
|
|
|
|
<input #input value="Message">
|
2018-07-14 21:23:14 +03:00
|
|
|
<button (click)="popup.showAsComponent(input.value)">Show as component</button>
|
|
|
|
|
<button (click)="popup.showAsElement(input.value)">Show as element</button>
|
|
|
|
|
`,
|
2018-02-27 13:33:41 -08:00
|
|
|
})
|
|
|
|
|
export class AppComponent {
|
2018-07-14 21:23:14 +03:00
|
|
|
constructor(injector: Injector, public popup: PopupService) {
|
|
|
|
|
// Convert `PopupComponent` to a custom element.
|
2018-07-11 16:34:56 +02:00
|
|
|
const PopupElement = createCustomElement(PopupComponent, {injector});
|
2018-07-14 21:23:14 +03:00
|
|
|
// Register the custom element with the browser.
|
|
|
|
|
customElements.define('popup-element', PopupElement);
|
2018-02-27 13:33:41 -08:00
|
|
|
}
|
|
|
|
|
}
|