import { Component, Injectable, ViewChild, ViewContainerRef, AfterViewInit } from '@angular/core'; import { CompileHtmlService } from '../../../src/CompileHtmlService'; @Component({ selector: 'p3x-ng2-compile-html', template: `
`, }) @Injectable() export class Page implements AfterViewInit{ @ViewChild('container', {read: ViewContainerRef}) container: ViewContainerRef; constructor( private compileHtmlService: CompileHtmlService ) {} alert(string: string ) { alert(string); } ngAfterViewInit() { this.compileHtmlService.compile({ template: `If click works it says OK!`, container: this.container, ref: this, }) } }