Scenario:
Todo List > New Todo Form > Todo Entry
Expectations:
When I go from Todo List to New Todo Form, the back button should go back to Todo List.
When I submit the New Todo Form, I should be taken to view the Todo Entry.
From the Todo Entry, the back button should go back to TodoList.
Actual Result:
When I hit the back button from Todo Entry, it would take me back to the New Todo Form.
Here’s the fix:
.controller('NewTodoCtrl', function($scope, $state, $ionicViewService) {
$scope.createTodo = function() {
// performing create tasks assigning the object `todo`
// ...
// get the this current view's previous view
var todoList = $ionicViewService.getBackView();
// assign it as the current view (as far as history is concerned)
$ionicViewService.setNavViews(todoList.viewId);
// proceed to the next view
$state.go('todo.view', {id: todo.id});
};
})
New result:
When I submit the New Todo Form, I am taken to view the Todo Entry.
When I hit the back button from the Todo Entry, I am taken to the Todo List.