@@ -38,10 +38,13 @@ export class TabViewDirective {
3838}
3939
4040@Directive ( {
41- selector : '[tabItem]'
41+ selector : '[tabItem]' ,
42+ inputs : [ 'title' , 'iconSource' ]
4243} )
4344export class TabViewItemDirective {
4445 private item : TabViewItem ;
46+ private _title : string ;
47+ private _iconSource : string ;
4548
4649 constructor (
4750 private owner : TabViewDirective ,
@@ -52,11 +55,34 @@ export class TabViewItemDirective {
5255
5356 @Input ( 'tabItem' ) config : any ;
5457
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+
5580 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+ }
6086
6187 const viewRef = this . viewContainer . createEmbeddedView ( this . templateRef ) ;
6288 //Filter out text nodes, etc
@@ -70,4 +96,4 @@ export class TabViewItemDirective {
7096 this . owner . tabView . items = newItems ;
7197 }
7298 }
73- }
99+ }
0 commit comments