From 10c76a64df313d8cb89166c7d920605147b1ee00 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 1 Dec 2015 09:43:09 -0600 Subject: [PATCH] feat(viewCtrl): setBackButtonText() --- ionic/components/nav/test/basic/index.ts | 20 ++++++++++++++++---- ionic/components/nav/view-controller.ts | 10 ++++++++++ ionic/components/navbar/navbar.ts | 4 ++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ionic/components/nav/test/basic/index.ts b/ionic/components/nav/test/basic/index.ts index d931e7ecdb..b9b9572945 100644 --- a/ionic/components/nav/test/basic/index.ts +++ b/ionic/components/nav/test/basic/index.ts @@ -70,10 +70,9 @@ class FirstPage { } onPageDidEnter() { - setTimeout(() => { - // Page2 will be transparent on first nav - this.nav.push(PrimaryHeaderPage); - }, 2000); + // setTimeout(() => { + // this.nav.push(PrimaryHeaderPage); + // }, 2000); } setPages() { @@ -208,6 +207,7 @@ class PrimaryHeaderPage {

+

` }) @@ -219,6 +219,7 @@ class AnotherPage { this.nav = nav; this.viewCtrl = viewCtrl; this.bbHideToggleVal = false; + this._bbCount = 0; } pushFullPage() { @@ -241,6 +242,17 @@ class AnotherPage { this.bbHideToggleVal = !this.bbHideToggleVal this.viewCtrl.showBackButton(this.bbHideToggleVal); } + + setBackButtonText() { + let backButtonText = 'Messages'; + + if (this._bbCount > 0) { + backButtonText += ` (${this._bbCount})`; + } + + this.viewCtrl.setBackButtonText(backButtonText); + ++this._bbCount; + } } diff --git a/ionic/components/nav/view-controller.ts b/ionic/components/nav/view-controller.ts index f8cf620f12..0c8a24ada8 100644 --- a/ionic/components/nav/view-controller.ts +++ b/ionic/components/nav/view-controller.ts @@ -207,6 +207,16 @@ export class ViewController { return navbar && navbar.getBackgroundRef(); } + /** + * @param {string} Set the back button text. + */ + setBackButtonText(val) { + let navbar = this.getNavbar(); + if (navbar) { + navbar.bbText = val; + } + } + /** * @param {boolean} Set if this Page's back button should show or not. */ diff --git a/ionic/components/navbar/navbar.ts b/ionic/components/navbar/navbar.ts index 54276c333d..dabe77ab62 100644 --- a/ionic/components/navbar/navbar.ts +++ b/ionic/components/navbar/navbar.ts @@ -68,7 +68,7 @@ class ToolbarBackground { '' + '' + @@ -108,7 +108,7 @@ export class Navbar extends ToolbarBase { viewCtrl && viewCtrl.setNavbar(this); this.bbIcon = config.get('backButtonIcon'); - this.bbDefault = config.get('backButtonText'); + this.bbText = config.get('backButtonText'); } /**