Rewriting history for linking to page under tab


One thing I’ve struggled with when using %ion-tabs is linking to a page underneath a main tab. e.g.
If you have a “More” tab with “Goals” under it, everything works beautifully when you go from More to Goals, history is correct and there’s a “< Back” menu to More.

I want to be able to link to the More > Goals from other tabs and have “< Back” go to More. e.g.
Coming from a notification to Goals I want the ‘< Back’ to go to More.

You could argue that Back should always go Back to the previous view, duh! For my use case Goals sits under More and people know where it is. One hacky way I’ve achieved what I want is to use something like this

@app.controller 'GoalsController', ['PreviousHistory', (PreviousHistory)->
  PreviousHistory.rewrite(['tab.more', {}, 'tab.goals', {}])

@app.factory 'PreviousHistory', ['$ionicHistory', '$state', '$timeout',($ionicHistory, $state, $timeout)->
  rewrite: (state1, state1Params, state2, state2Params)->
    prev = $ionicHistory.backView()
    return unless prev.stateId == "tab.notifications"

    $timeout ->
      $ionicHistory.nextViewOptions(disableAnimate: true)
      $state.go(state1, state1Params)
    $timeout ->
      $ionicHistory.nextViewOptions(disableAnimate: true)
      $state.go(state2, state2Params)


Is there a better way?


Sorry, I don’t have suggestions, I’m curious about what the user sees on screen when the 2 $state.go() calls are executed.

I wonder if there are developers who truly enjoy the tab navigation history feature of Ionic, most of the time I find it going inoi my way…