update document.title on view change

This commit is contained in:
Adam Bradley
2015-09-17 12:39:28 -05:00
parent a33073ca5f
commit 8a344cebd9
2 changed files with 16 additions and 9 deletions

View File

@@ -103,8 +103,7 @@ export class Navbar extends ToolbarBase {
}
didEnter() {
// const titleEle = this._ttEle || (this._ttEle = this.getNativeElement().querySelector('ion-title'));
// titleEle && this.app.title(titleEle.textContent);
this.app.title(this.getTitleText());
}
}

View File

@@ -21,16 +21,20 @@ export class ToolbarBase extends Ion {
this.titleRef = null;
}
setTitleCmp(titleCmp) {
this.titleCmp = titleCmp;
}
getTitleText() {
return (this.titleCmp && this.titleCmp.getTitleText()) || '';
}
/**
* TODO
* @returns {TODO} TODO
*/
getTitleRef() {
return this.titleRef;
}
setTitleRef(titleElementRef) {
this.titleRef = titleElementRef;
return this.titleCmp && this.titleCmp.elementRef.textContent;
}
/**
@@ -94,8 +98,12 @@ export class ToolbarTitle extends Ion {
@Optional() @Inject(forwardRef(() => Navbar)) navbar: Navbar
) {
super(elementRef, null);
toolbar && toolbar.setTitleRef(elementRef);
navbar && navbar.setTitleRef(elementRef);
toolbar && toolbar.setTitleCmp(this);
navbar && navbar.setTitleCmp(this);
}
getTitleText() {
return this.getNativeElement().textContent;
}
}