diff --git a/ionic/components/tabs/tab.ts b/ionic/components/tabs/tab.ts index 67c3cba1f0..00abbdab3a 100644 --- a/ionic/components/tabs/tab.ts +++ b/ionic/components/tabs/tab.ts @@ -101,7 +101,9 @@ export class Tab extends NavController { private _btnId: string; private _loaded: boolean; private _loadTimer: any; + btn: TabButton; + @Input() root: Type; @Input() tabTitle: string; @Input() tabIcon: string; @@ -123,7 +125,7 @@ export class Tab extends NavController { // A Tab is a NavController for its child pages super(parentTabs, app, config, keyboard, elementRef, 'contents', compiler, viewManager, zone, renderer); - this._isInitial = parentTabs.add(this); + parentTabs.add(this); this._panelId = 'tabpanel-' + this.id; this._btnId = 'tab-' + this.id; @@ -134,24 +136,6 @@ export class Tab extends NavController { */ ngOnInit() { this.tabBadgeStyle = this.tabBadgeStyle ? this.tabBadgeStyle : 'default'; - - if (this._isInitial) { - this.parent.select(this); - - } else if (this.parent.preloadTabs) { - this._loadTimer = setTimeout(() => { - if (!this._loaded) { - this.load({ - animate: false, - preload: true, - postLoad: (viewCtrl) => { - let navbar = viewCtrl.getNavbar(); - navbar && navbar.setHidden(true); - } - }, function(){}); - } - }, 1000 * this.index); - } } /** @@ -169,6 +153,21 @@ export class Tab extends NavController { } } + preload(wait) { + this._loadTimer = setTimeout(() => { + if (!this._loaded) { + this.load({ + animate: false, + preload: true, + postLoad: (viewCtrl) => { + let navbar = viewCtrl.getNavbar(); + navbar && navbar.setHidden(true); + } + }, function(){}); + } + }, wait); + } + /** * @private */ diff --git a/ionic/components/tabs/tabs.ts b/ionic/components/tabs/tabs.ts index 8c5b6e38b1..3a70291039 100644 --- a/ionic/components/tabs/tabs.ts +++ b/ionic/components/tabs/tabs.ts @@ -132,6 +132,15 @@ export class Tabs extends Ion { this.select(tab); }); }); + + this._tabs.forEach((tab, index) => { + if (index === 0) { + this.select(tab); + + } else if (this.preloadTabs) { + tab.preload(1000 * index); + } + }); } /** @@ -151,8 +160,6 @@ export class Tabs extends Ion { add(tab) { tab.id = this.id + '-' + (++this._ids); this._tabs.push(tab); - - return (this._tabs.length === 1); } /**