Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

$state.go sometimes mistakes state for nested view in tabs controller

$
0
0

@OJCode14 wrote:

I have a tabbed view app. I have a couple views that sit outside of the tabs controller, one being 'initial'. This is the first app view and contains the log in/sign up choice.

.state('initial', {
   url: '/initial',
  templateUrl: 'templates/initial.html',
  controller: 'initialCtrl'
})

Now, I have my settings view, which is a tab view with its own nested views

.state('tabsController.settings', {
   url: '/settings',
  views: {
   'tab4': {
      templateUrl: 'templates/settings.html',
      controller: 'settingsCtrl'
        }
  }
})

I have a 'log out' function in the settings controller which amongst other things like clearing cached user data, returns the user to the initial view:

$scope.doLogOut = function(){
        //deletes a few local storage values and then:
        $state.go('initial');
    }

The problem I've got is that seemingly sporadically I'll log in, then navigate to my settings tab, click logout and get booted back to 'initial', which is correct, but sometimes after that, clicking log in again will send me to my main page view but with a back button visible, as if it were a nested page of a tab view. I don't want the user to be able to go "back" from a successful log in. What is happening here and why is it seemingly random?

EDIT: I have solved this issue by using $ionicHistory in my settings controller and clearing the history with $ionicHistory.clearHistory() before $state.go ... Though it would be interesting to know why I have to do this if anyone knows?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>