fix(header): optional ViewController injection

This commit is contained in:
Adam Bradley
2016-06-17 12:15:01 -05:00
parent 64b867816a
commit 5a85d82b8a
2 changed files with 12 additions and 26 deletions

View File

@@ -1,7 +1,11 @@
<ion-header>
<ion-toolbar>
<ion-title>Default Buttons</ion-title>
</ion-toolbar>
</ion-header>
<ion-toolbar>
<ion-title>Default Buttons</ion-title>
</ion-toolbar>
<ion-content padding style="text-align:center">

View File

@@ -12,20 +12,11 @@ import {ViewController} from '../nav/view-controller';
selector: 'ion-header'
})
export class Header {
private _h: number = 0;
constructor(viewCtr: ViewController, private _elementRef: ElementRef) {
viewCtr.setHeader(this);
constructor(@Optional() viewCtr: ViewController) {
viewCtr && viewCtr.setHeader(this);
}
setHeight(heightPixels: number) {
this._h = heightPixels;
this._elementRef.nativeElement.style.height = (heightPixels > 0 ? heightPixels + 'px' : '');
}
getHeight(): number {
return this._h;
}
}
@@ -33,20 +24,11 @@ export class Header {
selector: 'ion-footer'
})
export class Footer {
private _h: number = 0;
constructor(viewCtr: ViewController, private _elementRef: ElementRef) {
viewCtr.setFooter(this);
constructor(@Optional() viewCtr: ViewController) {
viewCtr && viewCtr.setFooter(this);
}
setHeight(heightPixels: number) {
this._h = heightPixels;
this._elementRef.nativeElement.style.height = (heightPixels > 0 ? heightPixels + 'px' : '');
}
getHeight(): number {
return this._h;
}
}
@@ -109,7 +91,7 @@ export class ToolbarBase extends Ion {
* A Toolbar is a generic bar that is positioned above or below content.
* Unlike a [Navbar](../../nav/Navbar), a toolbar can be used as a subheader.
* When toolbars are placed within an `<ion-header>` or `<ion-footer>`,
* they stay fixed in their respective location. When placed within
* the toolbars stay fixed in their respective location. When placed within
* `<ion-content>`, toolbars will scroll with the content.
*
*