@@ -38,10 +38,13 @@ export class TabViewDirective {
38
38
}
39
39
40
40
@Directive ( {
41
- selector : '[tabItem]'
41
+ selector : '[tabItem]' ,
42
+ inputs : [ 'title' , 'iconSource' ]
42
43
} )
43
44
export class TabViewItemDirective {
44
45
private item : TabViewItem ;
46
+ private _title : string ;
47
+ private _iconSource : string ;
45
48
46
49
constructor (
47
50
private owner : TabViewDirective ,
@@ -52,11 +55,34 @@ export class TabViewItemDirective {
52
55
53
56
@Input ( 'tabItem' ) config : any ;
54
57
58
+ set title ( value : string ) {
59
+ if ( this . _title !== value ) {
60
+ this . _title = value ;
61
+ this . ensureItem ( ) ;
62
+ this . item . title = this . _title ;
63
+ }
64
+ }
65
+
66
+ set iconSource ( value : string ) {
67
+ if ( this . _iconSource !== value ) {
68
+ this . _iconSource = value ;
69
+ this . ensureItem ( ) ;
70
+ this . item . iconSource = this . _iconSource ;
71
+ }
72
+ }
73
+
74
+ private ensureItem ( ) {
75
+ if ( ! this . item ) {
76
+ this . item = new TabViewItem ( ) ;
77
+ }
78
+ }
79
+
55
80
ngOnInit ( ) {
56
- this . item = new TabViewItem ( ) ;
57
- this . item . title = this . config . title ;
58
-
59
- this . item . iconSource = this . config . iconSource ;
81
+ this . ensureItem ( ) ;
82
+ if ( this . config ) {
83
+ this . item . title = this . _title || this . config . title ;
84
+ this . item . iconSource = this . _iconSource || this . config . iconSource ;
85
+ }
60
86
61
87
const viewRef = this . viewContainer . createEmbeddedView ( this . templateRef ) ;
62
88
//Filter out text nodes, etc
@@ -70,4 +96,4 @@ export class TabViewItemDirective {
70
96
this . owner . tabView . items = newItems ;
71
97
}
72
98
}
73
- }
99
+ }
0 commit comments