Skip to content

Instantly share code, notes, and snippets.

Last active Jun 26, 2018
What would you like to do?
import {ɵrenderTemplate as renderTemplate} from '@angular/core'
export function withNgTemplate(Base = HTMLElement){
return class NgTemplateElement extends HTMLElement {
_renderRoot: HTMLElement | ShadowRoot;
_renderer(root:HTMLElement | ShadowRoot, renderFn:any){
this._host = renderTemplate(this._renderRoot as HTMLElement, (this.constructor as any).ngTemplate, this, {
createRenderer(){ return document; }
}, this._host, null, null, null );
this._renderer(this._renderRoot, () => this._render && this._render());
import {withNgTemplate} from '@angular/core'
class MyElement extends withNgTemplate(){
customElements.define('x-foo', MyElement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment