1
- import { Inject , Component , View } from 'angular2/core' ;
1
+ import { Component , Directive , Host , ElementRef , Input } from 'angular2/core' ;
2
2
3
3
@Component ( {
4
4
selector : 'templated-component' ,
5
+ directives : [ TemplatedComponent ] ,
5
6
templateUrl : 'title.html'
6
7
} )
7
8
export class TemplatedComponent {
9
+ @Input ( ) public renderChild : boolean = false ;
10
+ @Input ( ) public text : string = "Hello, external templates" ;
11
+ }
12
+
13
+ @Directive ( {
14
+ selector : 'Progress' ,
15
+ } )
16
+ export class ProgressComponent {
17
+ constructor ( private element : ElementRef ) {
18
+ }
19
+
20
+ ngOnInit ( ) {
21
+ this . element . nativeElement . value = 90 ;
22
+ }
8
23
}
9
24
10
25
@Component ( {
11
26
selector : 'renderer-test' ,
12
- directives : [ TemplatedComponent ] ,
27
+ directives : [ TemplatedComponent , ProgressComponent ] ,
13
28
template : `
14
29
<StackLayout orientation='vertical'>
15
- <templated-component *ngIf='showDetails' ></templated-component >
30
+ <Progress value="50" style="color: red" ></Progress >
16
31
<Label [class.valid]="isValid" [class.invalid]="!isValid" text='Name' fontSize='20' verticalAlignment='center' padding='20'></Label>
17
32
<TextField #name text='John' fontSize='20' padding='20'></TextField>
18
33
<Button [text]='buttonText' (tap)='onSave($event, name.text, $el)'></Button>
@@ -23,6 +38,7 @@ export class TemplatedComponent {
23
38
<TextField *ngFor='#detailLine of detailLines' [text]='detailLine'></TextField>
24
39
</StackLayout>
25
40
<Label text='==============================' fontSize='20'></Label>
41
+ <templated-component [renderChild]="true"></templated-component>
26
42
</StackLayout>
27
43
` ,
28
44
} )
@@ -41,9 +57,8 @@ export class RendererTest {
41
57
this . moreDetailsText = 'More details:' ;
42
58
43
59
this . detailLines = [
44
- "ngFor inside a ngIf" ,
45
- "Street address" ,
46
- "Country, city" ,
60
+ "ngFor inside a ngIf 1" ,
61
+ "ngFor inside a ngIf 2" ,
47
62
] ;
48
63
}
49
64
0 commit comments