mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(header): optional ViewController injection
This commit is contained in:
@@ -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">
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user