From 0fd6e915aaec48d92c38e20d064ea381f6568948 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 2 Dec 2014 15:43:28 -0600 Subject: [PATCH] fix($ionicTabsDelegate): find active tab instance --- js/angular/controller/tabsController.js | 15 ++++++++++++--- js/angular/directive/tabs.js | 4 +--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/js/angular/controller/tabsController.js b/js/angular/controller/tabsController.js index 814ed32707..f6d0a4a275 100644 --- a/js/angular/controller/tabsController.js +++ b/js/angular/controller/tabsController.js @@ -77,7 +77,7 @@ function($scope, $ionicHistory, $element) { (tab.onSelect || angular.noop)(); if (shouldEmitEvent) { - var viewData = { + $scope.$emit('$ionicHistory.change', { type: 'tab', tabIndex: tabIndex, historyId: tab.$historyId, @@ -86,9 +86,18 @@ function($scope, $ionicHistory, $element) { title: tab.title, url: tab.href, uiSref: tab.uiSref - }; - $scope.$emit('$ionicHistory.change', viewData); + }); } } }; + + self.hasActiveScope = function() { + for (var x = 0; x < self.tabs.length; x++) { + if ($ionicHistory.isActiveScope(self.tabs[x])) { + return true; + } + } + return false; + }; + }]); diff --git a/js/angular/directive/tabs.js b/js/angular/directive/tabs.js index e473e674c1..8f6cf60451 100644 --- a/js/angular/directive/tabs.js +++ b/js/angular/directive/tabs.js @@ -66,9 +66,7 @@ function($ionicTabsDelegate, $ionicConfig, $ionicHistory) { return { pre: prelink, post: postLink }; function prelink($scope, $element, $attr, tabsCtrl) { var deregisterInstance = $ionicTabsDelegate._registerInstance( - tabsCtrl, $attr.delegateHandle, function() { - return $ionicHistory.isActiveScope($scope); - } + tabsCtrl, $attr.delegateHandle, tabsCtrl.hasActiveScope ); tabsCtrl.$scope = $scope;