Skip to content

Commit

Permalink
fix(header): optional ViewController injection
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jun 17, 2016
1 parent 64b8678 commit 5a85d82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
10 changes: 7 additions & 3 deletions src/components/button/test/basic/main.html
Original file line number Diff line number Diff line change
@@ -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">

Expand Down
28 changes: 5 additions & 23 deletions src/components/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,23 @@ 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;
}
}


@Directive({
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;
}
}


Expand Down Expand Up @@ -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.
*
*
Expand Down

0 comments on commit 5a85d82

Please sign in to comment.