fix($ionicTabsDelegate): find active tab instance

This commit is contained in:
Adam Bradley
2014-12-02 15:43:28 -06:00
parent 767362bebd
commit 0fd6e915aa
2 changed files with 13 additions and 6 deletions

View File

@@ -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;
};
}]);

View File

@@ -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;