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
- <TabView>
15
- <TabView.items>
16
- <TabViewItem title="First Tab">
17
- <TabViewItem.view>
18
- <StackLayout orientation='vertical'>
19
- <templated-component></templated-component>
20
- <Label [class.valid]="isValid" [class.invalid]="!isValid" text='Name' fontSize='20' verticalAlignment='center' padding='20'></Label>
21
- <TextField #name text='John' fontSize='20' padding='20'></TextField>
22
- <Button [text]='buttonText' (tap)='onSave($event, name.text, $el)'></Button>
23
- <Button text='Toggle details' (tap)='onToggleDetails()'></Button>
24
- <TextView *ngIf='showDetails' [text]='detailsText'></TextView>
25
- <Label text='==============================' fontSize='20'></Label>
26
- <StackLayout #more *ngIf='showDetails' orientation='vertical'>
27
- <TextField *ngFor='#detailLine of detailLines' [text]='detailLine'></TextField>
28
- </StackLayout>
29
- <Label text='==============================' fontSize='20'></Label>
29
+ <StackLayout orientation='vertical'>
30
+ <Progress value="50" style="color: red"></Progress>
31
+ <Label [class.valid]="isValid" [class.invalid]="!isValid" text='Name' fontSize='20' verticalAlignment='center' padding='20'></Label>
32
+ <TextField #name text='John' fontSize='20' padding='20'></TextField>
33
+ <Button [text]='buttonText' (tap)='onSave($event, name.text, $el)'></Button>
34
+ <Button text='Toggle details' (tap)='onToggleDetails()'></Button>
35
+ <TextView *ngIf='showDetails' [text]='detailsText'></TextView>
36
+ <Label text='==============================' fontSize='20'></Label>
37
+ <StackLayout #more *ngIf='showDetails' orientation='vertical'>
38
+ <TextField *ngFor='#detailLine of detailLines' [text]='detailLine'></TextField>
30
39
</StackLayout>
31
- </TabViewItem.view>
32
- </TabViewItem>
33
- <TabViewItem title="Second Tab">
34
- <TabViewItem.view>
35
- <Label text="Completely different tab!"></Label>
36
- </TabViewItem.view>
37
- </TabViewItem>
38
- </TabView.items>
39
- </TabView>
40
+ <Label text='==============================' fontSize='20'></Label>
41
+ <templated-component [renderChild]="true"></templated-component>
42
+ </StackLayout>
40
43
` ,
41
44
} )
42
45
export class RendererTest {
@@ -54,9 +57,8 @@ export class RendererTest {
54
57
this . moreDetailsText = 'More details:' ;
55
58
56
59
this . detailLines = [
57
- "ngFor inside a ngIf" ,
58
- "Street address" ,
59
- "Country, city" ,
60
+ "ngFor inside a ngIf 1" ,
61
+ "ngFor inside a ngIf 2" ,
60
62
] ;
61
63
}
62
64
0 commit comments