Skip to content

Commit 53f4417

Browse files
amcdnljosephperrott
authored andcommitted
chore(nit): update per feedback
1 parent be835a3 commit 53f4417

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/lib/tabs/tab-content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Directive, TemplateRef} from '@angular/core';
22

3-
@Directive({ selector: '[mdTabContent]' })
3+
@Directive({selector: '[mdTabContent]'})
44
export class MdTabContent {
55
constructor(public template: TemplateRef<any>) { }
66
}

src/lib/tabs/tab-group.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ describe('lazy loaded tabs', () => {
418418
TestBed.compileComponents();
419419
}));
420420

421-
it('should lazy load the second tab', (done) => {
421+
it('should lazy load the second tab', async () => {
422422
let fixture = TestBed.createComponent(TemplateTabs);
423423
fixture.detectChanges();
424424

@@ -430,7 +430,6 @@ describe('lazy loaded tabs', () => {
430430
fixture.detectChanges();
431431
let child = fixture.debugElement.query(By.css('.child'));
432432
expect(child.nativeElement).toBeDefined();
433-
done();
434433
});
435434
});
436435
});

src/lib/tabs/tabs.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,28 @@ Tabs without text or labels should be given a meaningful label via `aria-label`
9292
| `LEFT_ARROW` | Move focus to previous tab |
9393
| `RIGHT_ARROW` | Move focus to next tab |
9494
| `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+
```

0 commit comments

Comments
 (0)