Transitioning between views without navigation


#1

I’m trying to understand how I can transition between views in Ionic. Every time I do a $state.go it just pushes yet another view onto the stack. I want to go to a new screen without retaining any prior screen in memory anywhere, and without the ability to back. One example of this is that I have a loading screen when the app starts, and then it switches to my main tabbed view controller. But I want my loading screen ui to be completely discarded from memory. I JUST started trying out ionic and am fairly new to javascript so please don’t assume I know anything in your answer.


#2

Try this:

$state.go('someView', {}, {location: 'replace'});

#3

Thanks. This sounds perfect!


#4

Unfortunately, that did not work as expected :(. If I come back to the original view later on, all its state was retained and so basically the view was never destroyed. I want to be able to move to a new state while making sure the old state is no longer retained in memory. Can someone please show me how to completely deallocate the prior view controller?


#5

try

$ionicHistory.clearHistory() in your tabbed view controller which loads after the loading screen. This removes the previous history and going back does not work.


#6

Ok thanks I’ll do that. Also what helped me was using ion-view cache-view=“false” in my source view controller.


#7

Ok I ended up needing to use the clearHistory anyway because of an occasional back button that was showing up; this fixed that. Thanks!