From 4af71261cf3a2c4a51bec16a274ca8ea9ed6f8e1 Mon Sep 17 00:00:00 2001 From: mhartington Date: Mon, 21 Dec 2015 14:52:01 -0500 Subject: [PATCH] docs(tab): add section about select --- ionic/components/tabs/tab.ts | 45 +++++++++++++++++++++++++++++++++-- ionic/components/tabs/tabs.ts | 4 ++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ionic/components/tabs/tab.ts b/ionic/components/tabs/tab.ts index 80df2b5319..f6ca1a1676 100644 --- a/ionic/components/tabs/tab.ts +++ b/ionic/components/tabs/tab.ts @@ -32,12 +32,53 @@ import {Tabs} from './tabs'; * * See the [Tabs API reference](../Tabs/) for more details on configuring Tabs * and the TabBar. - + * + * For most cases, you can give tab a `[root]` property along with the component you want to load. + * + * ```html + * + * + * + * ``` + * + * ```ts + * import {Chat} from '../chat/chat'; + * export class Tabs { + * constructor(){ + * // here we'll set the property of chatRoot to + * // the imported class of Chat + * this.chatRoot = Chat + * } + * } + * ``` + * + * In other cases, you may not want to navigate to a new component, but just call a method. + * You can use the `(select)` event to call a method on your class. + * + * ```html + * + * + * + * ``` + * + * ```ts + * export class Tabs { + * constructor(modal: Modal){ + * this.modal = modal; + * } + * chat() { + * this.modal.open(ChatPage); + * } + * } + * ``` + * In this case, when we tap on the tab, we'll open a modal instead of loading a new component. + * * * @property {any} [root] - set the root page for this tab * @property {any} [tabTitle] - set the title of this tab * @property {any} [tabIcon] - set the icon for this tab - + * @property {any} [select] - method to call when the current tab is selected + * */ @Component({ selector: 'ion-tab', diff --git a/ionic/components/tabs/tabs.ts b/ionic/components/tabs/tabs.ts index 9f438f68bd..ba1eabe21b 100644 --- a/ionic/components/tabs/tabs.ts +++ b/ionic/components/tabs/tabs.ts @@ -84,7 +84,7 @@ export class Tabs extends Ion { elementRef: ElementRef, @Optional() viewCtrl: ViewController, @Optional() navCtrl: NavController, - private platform: Platform + private _platform: Platform ) { super(elementRef, config); this.parent = navCtrl; @@ -116,7 +116,7 @@ export class Tabs extends Ion { this.preloadTabs = (this.preloadTabs !== "false" && this.preloadTabs !== false); if (this._highlight) { - this.platform.onResize(() => { + this._platform.onResize(() => { this._highlight.select(this.getSelected()); }); }