How to show back button from direct hit

Let’s say we have these two states.

.state('app.profile', {
    url: '/profile',
    views: {
        'app-profile': {
            templateUrl: 'templates/app/app-profile-view.html',
            controller: 'ProfileCtrl'
        }
    }
})

.state('app.edit-profile', {
    url: '/edit-profile',
    views: {
        'app-profile': {
            templateUrl: 'templates/app/app-edit-profile-view.html',
            controller: 'EditProfileCtrl'
        }
    }
})

Where profile is inside a tabs stack.

<!-- Profile Tab -->
<ion-tab title="Profile" icon-on="ion-ios7-person" icon-off="ion-ios7-person-outline" ui-sref="app.profile">
    <ion-nav-view name="app-profile"></ion-nav-view>
</ion-tab>

If I click on the profile tab, I’m shown my profile view, and if I click on Edit Profile it transitions to the edit profile page great, and shows the back arrow fantastically.

Let’s say however, they start up the app, and I want to start on the Edit Profile page? If I do that, I’d like for them to be able to navigate back to the Profile page via the back arrow. But when I do $state.go('app.edit-profile'), no back arrow is shown.

I understand this is probably because their isn’t a history, but is there a way I could create one?

Hey,

It’s a bit hacky but you could use the loaded event to do this. Basically the loaded event it only called once. In the loaded event of your default view, you could navigate to your profile view and this will create the history.

When you hit back the loaded event won’t fire.

Check out this page http://ionicframework.com/docs/api/directive/ionView/