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