@@ -24,6 +24,7 @@ import {
2424import { CanDisable , mixinDisabled } from '@angular/material/core' ;
2525import { Subject } from 'rxjs/Subject' ;
2626import { MatTabLabel } from './tab-label' ;
27+ import { MatTabContent } from './tab-content' ;
2728
2829
2930// Boilerplate for applying mixins to MatTab.
@@ -45,8 +46,13 @@ export class MatTab extends _MatTabMixinBase implements OnInit, CanDisable, OnCh
4546 /** Content for the tab label given by `<ng-template mat-tab-label>`. */
4647 @ContentChild ( MatTabLabel ) templateLabel : MatTabLabel ;
4748
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 > ;
5056
5157 /** The plain text label for the tab, used when there is no template label. */
5258 @Input ( 'label' ) textLabel : string = '' ;
@@ -102,6 +108,7 @@ export class MatTab extends _MatTabMixinBase implements OnInit, CanDisable, OnCh
102108 }
103109
104110 ngOnInit ( ) : void {
105- this . _contentPortal = new TemplatePortal ( this . _content , this . _viewContainerRef ) ;
111+ this . _contentPortal = new TemplatePortal (
112+ this . _explicitContent || this . _implicitContent , this . _viewContainerRef ) ;
106113 }
107114}
0 commit comments