Skip to content

Instantly share code, notes, and snippets.

@joshbuchea
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshbuchea/21ea32cbdfd7b063a739 to your computer and use it in GitHub Desktop.
Save joshbuchea/21ea32cbdfd7b063a739 to your computer and use it in GitHub Desktop.
Ionic navClear directive replacement for beta 14+
.directive('navClear', [
'$ionicHistory',
'$state',
'$location',
'$window',
'$rootScope',
function($ionicHistory, $location, $state, $window, $rootScope) {
$rootScope.$on('$stateChangeError', function() {
$ionicHistory.nextViewOptions(null);
});
return {
priority: 100,
restrict: 'AC',
compile: function($element) {
return { pre: prelink };
function prelink($scope, $element, $attrs) {
var unregisterListener;
function listenForStateChange() {
unregisterListener = $scope.$on('$stateChangeStart', function() {
$ionicHistory.nextViewOptions({
disableAnimate: true,
disableBack: true
});
unregisterListener();
});
$window.setTimeout(unregisterListener, 300);
}
$element.on('click', listenForStateChange);
}
}
};
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment