@@ -24,6 +24,7 @@ import {
24
24
import { CanDisable , mixinDisabled } from '@angular/material/core' ;
25
25
import { Subject } from 'rxjs/Subject' ;
26
26
import { MatTabLabel } from './tab-label' ;
27
+ import { MatTabContent } from './tab-content' ;
27
28
28
29
29
30
// Boilerplate for applying mixins to MatTab.
@@ -45,8 +46,13 @@ export class MatTab extends _MatTabMixinBase implements OnInit, CanDisable, OnCh
45
46
/** Content for the tab label given by `<ng-template mat-tab-label>`. */
46
47
@ContentChild ( MatTabLabel ) templateLabel : MatTabLabel ;
47
48
48
- /** Template inside the MatTab view that contains an `<ng-content>`. */
49
- @ViewChild ( TemplateRef ) _content : TemplateRef < any > ;
49
+ /**
50
+ * Template provided in the tab content that will be used if present, used to enable lazy-loading
51
+ */
52
+ @ContentChild ( MatTabContent , { read : TemplateRef } ) _explicitContent : TemplateRef < any > ;
53
+
54
+ /** Template inside the MatTab view that contains an <ng-content>. */
55
+ @ViewChild ( TemplateRef ) _implicitContent : TemplateRef < any > ;
50
56
51
57
/** The plain text label for the tab, used when there is no template label. */
52
58
@Input ( 'label' ) textLabel : string = '' ;
@@ -102,6 +108,7 @@ export class MatTab extends _MatTabMixinBase implements OnInit, CanDisable, OnCh
102
108
}
103
109
104
110
ngOnInit ( ) : void {
105
- this . _contentPortal = new TemplatePortal ( this . _content , this . _viewContainerRef ) ;
111
+ this . _contentPortal = new TemplatePortal (
112
+ this . _explicitContent || this . _implicitContent , this . _viewContainerRef ) ;
106
113
}
107
114
}
0 commit comments