Back navigation: non-deterministic behavior


#1

Setup
I have 2 views: A and B. On A I have a list with pagination (using ion-infinite-scroll). On B I have a detail view about an item (from A’s list).

Problem
When I scrolling down on view A new pages are loaded. When I go to detail of an item (nav A -> B) and the return from her (nav A <- B), instead of pop B from view history, the Ionic pushes a new entry of A on views history. Furthermore, when I click on back button of A, the B appears again and I stay on infinite loop: A -> B -> A -> B -> A -> B … and so on.

This problem only occurs when a new page is loaded on A. If none new page is loaded, the flow of navigation occurs as expected.

Someone can help me?


#2

I found the problem origin and I already resolve him.


#3

Could you share the solution with us and future readers (via Google)?


#4

Yes, @Sujan12.

I don’t know the exact reason, but the way as I put the received items on the list of the view A, it was the origin of the problem.

Before:

function onReceive(newItems) {
  newItems.forEach(function(newItem) {
    vm.items.push(newItem);
  });
}

After:

function onReceive(newItems) {
  vm.items = vm.items.concat(newItems);
}

Like the problem, the solution is very weird.