diff --git a/ionic/components/tabs/tabs.ts b/ionic/components/tabs/tabs.ts index 3a70291039..e689955030 100644 --- a/ionic/components/tabs/tabs.ts +++ b/ionic/components/tabs/tabs.ts @@ -46,8 +46,8 @@ import {isUndefined} from '../../util/util'; '' + '' + '' + - '' + - '{{t.tabTitle}}' + + '' + + '{{t.tabTitle}}' + '{{t.tabBadge}}' + '' + '' + @@ -75,6 +75,7 @@ export class Tabs extends Ion { navbarContainerRef: ViewContainerRef; subPages: boolean; + @Input() selectedIndex: any; @Input() preloadTabs: any; @Input() tabbarIcons: string; @Input() tabbarPlacement: string; @@ -133,8 +134,10 @@ export class Tabs extends Ion { }); }); + let selectedIndex = this.selectedIndex ? parseInt(this.selectedIndex, 10) : 0; + this._tabs.forEach((tab, index) => { - if (index === 0) { + if (index === selectedIndex) { this.select(tab); } else if (this.preloadTabs) { @@ -206,10 +209,10 @@ export class Tabs extends Ion { this._tabs.forEach(tab => { tab.setSelected(tab === selectedTab); }); - } - if (this._useHighlight) { - this._highlight.select(selectedTab); + if (this._useHighlight) { + this._highlight.select(selectedTab); + } } selectedPage && selectedPage.didEnter(); diff --git a/ionic/components/tabs/test/tab-bar-scenarios/index.ts b/ionic/components/tabs/test/tab-bar-scenarios/index.ts index 834efa41bb..45d9e0103e 100644 --- a/ionic/components/tabs/test/tab-bar-scenarios/index.ts +++ b/ionic/components/tabs/test/tab-bar-scenarios/index.ts @@ -1,9 +1,17 @@ -import {App} from 'ionic/ionic'; +import {App, Page} from 'ionic/ionic'; + + +@Page({template:'hi'}) +class E2EPage{} @App({ templateUrl: 'main.html' }) -class E2EApp {} +class E2EApp { + constructor() { + this.root = E2EPage; + } +} document.body.innerHTML += '' diff --git a/ionic/components/tabs/test/tab-bar-scenarios/main.html b/ionic/components/tabs/test/tab-bar-scenarios/main.html index 3cd9811455..a221a414d3 100644 --- a/ionic/components/tabs/test/tab-bar-scenarios/main.html +++ b/ionic/components/tabs/test/tab-bar-scenarios/main.html @@ -1,71 +1,71 @@ - - - + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + +