File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { Directive , TemplateRef } from '@angular/core' ;
2
2
3
- @Directive ( { selector : '[mdTabContent]' } )
3
+ @Directive ( { selector : '[mdTabContent]' } )
4
4
export class MdTabContent {
5
5
constructor ( public template : TemplateRef < any > ) { }
6
6
}
Original file line number Diff line number Diff line change @@ -418,7 +418,7 @@ describe('lazy loaded tabs', () => {
418
418
TestBed . compileComponents ( ) ;
419
419
} ) ) ;
420
420
421
- it ( 'should lazy load the second tab' , ( done ) => {
421
+ it ( 'should lazy load the second tab' , async ( ) => {
422
422
let fixture = TestBed . createComponent ( TemplateTabs ) ;
423
423
fixture . detectChanges ( ) ;
424
424
@@ -430,7 +430,6 @@ describe('lazy loaded tabs', () => {
430
430
fixture . detectChanges ( ) ;
431
431
let child = fixture . debugElement . query ( By . css ( '.child' ) ) ;
432
432
expect ( child . nativeElement ) . toBeDefined ( ) ;
433
- done ( ) ;
434
433
} ) ;
435
434
} ) ;
436
435
} ) ;
Original file line number Diff line number Diff line change @@ -92,3 +92,28 @@ Tabs without text or labels should be given a meaningful label via `aria-label`
92
92
| ` LEFT_ARROW ` | Move focus to previous tab |
93
93
| ` RIGHT_ARROW ` | Move focus to next tab |
94
94
| ` SPACE ` or 'ENTER' | Switch to focused tab |
95
+
96
+
97
+ ## Lazy Loading
98
+ By default, the tab contents are eagerly loaded. Eagerly loaded tabs
99
+ will initalize the child components but not inject them into the DOM
100
+ until the tab is activated.
101
+
102
+ If the tab contains several complex child components, it is advised
103
+ to lazy load the tab's content. Tab contents can be lazy loaded by
104
+ declaring the body in a ` ng-template ` with the ` mdTabContent ` attribute.
105
+
106
+ ``` html
107
+ <md-tab-group >
108
+ <md-tab label =" First" >
109
+ <ng-template mdTabContent >
110
+ The First Content
111
+ </ng-template >
112
+ </md-tab >
113
+ <md-tab label =" Second" >
114
+ <ng-template mdTabContent >
115
+ The Second Content
116
+ </ng-template >
117
+ </md-tab >
118
+ </md-tab-group >
119
+ ```
You can’t perform that action at this time.
0 commit comments