From 8a344cebd9ed101d25117fa9377db656a9564575 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 17 Sep 2015 12:39:28 -0500 Subject: [PATCH] update document.title on view change --- ionic/components/nav-bar/nav-bar.ts | 3 +-- ionic/components/toolbar/toolbar.ts | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ionic/components/nav-bar/nav-bar.ts b/ionic/components/nav-bar/nav-bar.ts index 001cbea74a..ed1773d6db 100644 --- a/ionic/components/nav-bar/nav-bar.ts +++ b/ionic/components/nav-bar/nav-bar.ts @@ -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()); } } diff --git a/ionic/components/toolbar/toolbar.ts b/ionic/components/toolbar/toolbar.ts index 837304606d..dca04bff82 100644 --- a/ionic/components/toolbar/toolbar.ts +++ b/ionic/components/toolbar/toolbar.ts @@ -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; } }