fix(tabs): remove cache=false tab view element

This commit is contained in:
Adam Bradley
2014-12-02 23:49:36 -06:00
parent 0fd6e915aa
commit ab99b13be8
3 changed files with 127 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ IonicModule
function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate, $ionicNavViewDelegate, $ionicHistory, $ionicViewSwitcher) {
var DATA_ELE_IDENTIFIER = '$eleId';
var DATA_DESTROY_ELE = '$destroyEle';
var VIEW_STATUS_ACTIVE = 'active';
var VIEW_STATUS_CACHED = 'cached';
var HISTORY_AFTER_ROOT = 'after-root';
@@ -41,6 +42,8 @@ function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate,
var deregisterInstance = $ionicNavViewDelegate._registerInstance(self, $attrs.delegateHandle);
$scope.$on('$destroy', deregisterInstance);
$scope.$on('$ionicHistory.deselect', self.cacheCleanup);
return viewData;
};
@@ -159,6 +162,16 @@ function($scope, $element, $attrs, $compile, $controller, $ionicNavBarDelegate,
};
self.cacheCleanup = function() {
var viewElements = $element.children();
for (var x = 0, l = viewElements.length; x < l; x++) {
if (viewElements.eq(x).data(DATA_DESTROY_ELE)) {
$ionicViewSwitcher.destroyViewEle(viewElements.eq(x));
}
}
};
self.clearCache = function() {
var viewElements = $element.children();
var viewElement, viewScope;