File tree Expand file tree Collapse file tree 2 files changed +28
-18
lines changed
Expand file tree Collapse file tree 2 files changed +28
-18
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " p3x-ng2-compile-html" ,
3- "version" : " 1.0.33-16 " ,
4- "version-date" : " 1/16/2017, 8:28:21 PM" ,
3+ "version" : " 1.0.35-18 " ,
4+ "version-date" : " 1/16/2017, 8:53:13 PM" ,
55 "description" : " Angular 2 Service to compile an HTML into a component Edit" ,
66 "main" : " src/index.ts" ,
77 "scripts" : {
Original file line number Diff line number Diff line change @@ -11,42 +11,52 @@ import {CompileHtmlService } from '../../../src';
1111@Component ( {
1212 selector : 'p3x-ng2-compile-html-text' ,
1313 template : `
14- <div #container>loading ...</div>
15- <div [p3xCompileHtml]="data" [p3xCompileHtmlRef]="ref">loading ...</div>
14+ <div #container></div>
15+ <hr/>
16+ <div [p3xCompileHtml]="data2" [p3xCompileHtmlRef]="ref"></div>
1617` ,
1718} )
1819@Injectable ( )
1920export class Page implements OnInit {
2021
2122 @ViewChild ( 'container' , { read : ViewContainerRef } ) container : ViewContainerRef ;
2223
23- data : string ;
24+ data1 : string ;
25+ data2 : string ;
2426
2527 ref : Page ;
2628
27- counter : number = 0 ;
29+ counter1 : number = 0 ;
30+ counter2 : number = 0 ;
2831
2932 constructor ( private compileHtmlService : CompileHtmlService ) {
3033 this . ref = this ;
31- this . update ( ) ;
3234 }
3335
34- private update ( ) {
35- this . counter = this . counter + 1 ;
36- this . data = `<div>Done</div><a href="javascript:void(0);" (click)="ref.alert('ok')">If click works it says OK!</a>${ this . counter } ` ;
36+ private update1 ( ) {
37+ this . counter1 ++ ;
38+ this . data1 = `
39+ <div>Service</div><a href="javascript:void(0);" (click)="ref.update1()">Click me via a service!</a>
40+ <div>${ this . counter1 } </div>
41+ ` ;
42+ this . compileHtmlService . compile ( {
43+ template : this . data1 ,
44+ container : this . container ,
45+ ref : this ,
46+ } )
3747 }
3848
39- alert ( string : string ) {
40- alert ( string ) ;
41- this . update ( ) ;
49+ private update2 ( ) {
50+ this . counter2 ++ ;
51+ this . data2 = `
52+ <div>Attribute</div><a href="javascript:void(0);" (click)="ref.update2()">Click me via a service!</a>
53+ <div>${ this . counter2 } </div>
54+ ` ;
4255 }
4356
4457 ngOnInit ( ) {
45- this . compileHtmlService . compile ( {
46- template : this . data ,
47- container : this . container ,
48- ref : this ,
49- } )
58+ this . update1 ( ) ;
59+ this . update2 ( ) ;
5060 }
5161
5262}
You can’t perform that action at this time.
0 commit comments