Skip to content

Commit 5a85d82

Browse files
committed
fix(header): optional ViewController injection
1 parent 64b8678 commit 5a85d82

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

src/components/button/test/basic/main.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
<ion-header>
2+
3+
<ion-toolbar>
4+
<ion-title>Default Buttons</ion-title>
5+
</ion-toolbar>
6+
7+
</ion-header>
18

2-
<ion-toolbar>
3-
<ion-title>Default Buttons</ion-title>
4-
</ion-toolbar>
59

610
<ion-content padding style="text-align:center">
711

src/components/toolbar/toolbar.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,23 @@ import {ViewController} from '../nav/view-controller';
1212
selector: 'ion-header'
1313
})
1414
export class Header {
15-
private _h: number = 0;
1615

17-
constructor(viewCtr: ViewController, private _elementRef: ElementRef) {
18-
viewCtr.setHeader(this);
16+
constructor(@Optional() viewCtr: ViewController) {
17+
viewCtr && viewCtr.setHeader(this);
1918
}
2019

21-
setHeight(heightPixels: number) {
22-
this._h = heightPixels;
23-
this._elementRef.nativeElement.style.height = (heightPixels > 0 ? heightPixels + 'px' : '');
24-
}
25-
26-
getHeight(): number {
27-
return this._h;
28-
}
2920
}
3021

3122

3223
@Directive({
3324
selector: 'ion-footer'
3425
})
3526
export class Footer {
36-
private _h: number = 0;
3727

38-
constructor(viewCtr: ViewController, private _elementRef: ElementRef) {
39-
viewCtr.setFooter(this);
28+
constructor(@Optional() viewCtr: ViewController) {
29+
viewCtr && viewCtr.setFooter(this);
4030
}
4131

42-
setHeight(heightPixels: number) {
43-
this._h = heightPixels;
44-
this._elementRef.nativeElement.style.height = (heightPixels > 0 ? heightPixels + 'px' : '');
45-
}
46-
47-
getHeight(): number {
48-
return this._h;
49-
}
5032
}
5133

5234

@@ -109,7 +91,7 @@ export class ToolbarBase extends Ion {
10991
* A Toolbar is a generic bar that is positioned above or below content.
11092
* Unlike a [Navbar](../../nav/Navbar), a toolbar can be used as a subheader.
11193
* When toolbars are placed within an `<ion-header>` or `<ion-footer>`,
112-
* they stay fixed in their respective location. When placed within
94+
* the toolbars stay fixed in their respective location. When placed within
11395
* `<ion-content>`, toolbars will scroll with the content.
11496
*
11597
*

0 commit comments

Comments
 (0)