In this thread, Programatically change active tab on Ionic, two ways to programmatically change the active tab using select()
emerged.
The solutions assumes the following scenario. You have 3 children pages, and one tabs page to house your children. Your current navigation is in one of the child, and you want to go to another child programmatically.
The solutions posted on the thread, which I confirmed working for at least one of them are:
-
this.nav.parent.select(tabIndex);
, with tabIndex being a number, eg 2 if currently on tab 0 or 1. this.app.getRootNav().getActiveChildNav().select(tabIndex);
I’d like to know if someone knows how to use select()
and pass in some params with it?
I’ve tried this.nav.parent.select(tabIndex, {"key":"value"});
on the current tab, and on the tab that I navigate to, use NavParams
to try to this.navParams.get('key')
, but this does not work.
Edit: I ended up using a provider to set a value before calling select()
, and on the second tab that I navigate to, I use a getter using a Observable on page enter to listen to that provider’s value. It’s very heavy handed, and I did not want to use Local Storage because I feel that that’s persistent data and I don’t need it to persist.