Ionic looses history on switching to other state with different ion-tabs

When I am switching from one page that contains ion-tabs directive to another, ionic looses history. Do you know how to fix it or at least could you point me which part of code is responsible for it?

It's actually just an unfortunate part of the ionic design. Each navview has it own history stack, as does the tabs directive, so history is only tracked as long as you are in that context. Switching to a state in a new nav view will restart your history tracking. I have been working on a custom histry service that actually tracks your history globally, but I keep ending up with weird side effects from the tabs, kind of tricky.

Ionic tabs don't lose history unless you have messed up with. By history I mean if you are page 2 of tab 1 and clicked tab 2 and after sometime returned back, tab 1 will still be in page 2.

If you are confusing it with state, you will have to dive deep into ui-router.

Also $ionicViewService could be helpful for your purpose. But unfortunately no clear documentation is available for your use.