feat(tabs): add change event

This commit is contained in:
Adam Bradley
2015-12-21 10:45:01 -06:00
parent 0dd6b2f4bd
commit 6c4dced0b6
3 changed files with 9 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import {Directive, ElementRef, Optional, Host, forwardRef, ViewContainerRef, HostListener} from 'angular2/core';
import {EventEmitter, Output} from 'angular2/core';
import {NgFor, NgIf} from 'angular2/common';
import {Ion} from '../ion';
@ -68,6 +69,8 @@ import {rafFrames} from '../../util/dom';
]
})
export class Tabs extends Ion {
@Output() change: EventEmitter<any> = new EventEmitter();
/**
* Hi, I'm "Tabs". I'm really just another Page, with a few special features.
* "Tabs" can be a sibling to other pages that can be navigated to, which those
@ -163,6 +166,7 @@ export class Tabs extends Ion {
selectedTab.load(opts, () => {
selectedTab.emitSelect();
this.change.emit(selectedTab);
if (selectedTab.root) {
// only show the selectedTab if it has a root

View File

@ -63,6 +63,10 @@ class TabsPage {
console.log('Chat clicked!');
this.modal.open(ChatPage);
}
onTabChange() {
console.log('onTabChange');
}
}

View File

@ -1,5 +1,5 @@
<ion-tabs preloadTabs="false">
<ion-tabs preloadTabs="false" (change)="onTabChange()">
<ion-tab tabTitle="Recents" tabIcon="call" [root]="tab1Root"></ion-tab>
<ion-tab tabTitle="Favorites" tabIcon="star" [root]="tab2Root"></ion-tab>
<ion-tab tabTitle="Settings" tabIcon="settings" [root]="tab3Root"></ion-tab>