Back button and $stateChangeStart listener


#1

Hello all,

I’ve been experiencing a strange behavior on a side menu-like app with ionic 1.0.0-beta13.
The problem is basically that the ion-nav-back-button on the header of the menu is shown after navigating, even if I use nav-clear on all the menu options. I found that it’s related to the use of a $stateChangeStart listener on $rootScope.

You can reproduce this behavior in the following codepen: http://codepen.io/anon/pen/azdGzo?editors=101 by just navigating like this: “Check-in” -> “Attendees” -> “Home” -> “Check-in”.
You’ll see that after the last navigation the arrow back appears on the left of the menu button. Nevertheless it doesn’t happen if you comment out the $rootScope.$on($stateChangeStart... (lines 45-49).

Is this a bug?

To achieve the same result (setting a scope property to false as soon as a specific state is left), now I’m using $scope.$on("$destroy"..., but I’m not sure if the $destroy event is guaranteed to arrive when the user leaves the screen. Is there a better way of implementing this?.

Thanks in advance.
Regards,
Rafa.


#2

I forgot to mention I also had found the same problem in ionic1.0.0-beta8, see: Side menu with back button and nav-clear issue


#3

I’m also experiencing this


#4

This has all been refactored in beta14, specifically the enable-menu-with-back-views attribute, and I encourage you to test it out: Please help test: Angular 1.3, improved transitions, cached views (repost)


#5

@adam looks like its still an issue on the latest nightly.


#6

@cyprusglobe Please fork http://codepen.io/ionic/pen/tcIGK to recreate the issue you’re having. Thanks


#7

Indeed I tried but couldn’t reproduce it with the nightly build: http://codepen.io/anon/pen/azNzwz?editors=101
What’s strange is I see that each controller is only run once, even if you go back to any of the states.
Is that a behavior change in beta14 (or angular 1.3)? Perhaps the view is cached, right?.

EDIT: yeah, definitely it’s the view caching.