mtpultz
mtpultz

Reputation: 18268

Clearing Ionic History so ionNavBackButton isn't Displayed Not Working

I have an intro of slides before the user is redirected to login, but when I switch to the login the back history is displayed, and I'd rather it wasn't. Using $ionicHistory.clearHistory() before changing state doesn't appear to do anything, and the back button is still displayed.

.controller( 'IntroController', [ '$scope', '$state', '$ionicSlideBoxDelegate', '$ionicHistory',
    function( $scope, $state, $ionicSlideBoxDelegate, $ionicHistory ) {

        // Skip the introduction, and redirect to login
        $scope.skipIntro = function() {

            $ionicHistory.clearHistory();
            $state.go( 'login.index' );
        };

        ...

    } ] )

Other than just hiding the back button using CSS on the login, which seems like a UI hack, can this be achieved through the Ionic API?

UPDATE

For now I'm using

hide-back-button="true"

on the ion-view, but even though this works I'd still like to know how clear the browser history for other parts of the application.

Upvotes: 0

Views: 970

Answers (1)

InfinitePrime
InfinitePrime

Reputation: 1776

On your back button use nav-clear directive. This will clear navigation stack history.

Upvotes: 1

Related Questions