In ionic1, what is the equivalent function of this.nav.setRoot(Page1) and this.nav.push(Page2) in ionic2?


#1

For a navigation based app, in ionic2, if I want to start navigation from Page1, I can call:

this.nav.push(Page1);

and if I want to add next page, I can call:

this.nav.push(Page2);

, however, now I need to use ionic1, and I can only find something like:

.state('tabs.abc', {
  url: "/abc",
  views: {
    'abc-tab': {
      templateUrl: "templates/abc.html",
      controller: 'ABCTabCtrl'
    }
  }
})

which seems always switch views by changing states. My question is, in ionic1, how to I distinguish between this.nav.setRoot(Page1) and this.nav.push(Page2) ?


#2

http://man.hubwiz.com/docset/Ionic.docset/Contents/Resources/Documents/ionicframework.com/docs/api/service/$ionicHistory/index.html

According to the docs…

$ionicHistory.nextViewOptions({
  historyRoot: true,
  disableBack: true
});

…followed with…

$state.go('PageTwo');

…should do the trick.