How to restore stack page in tab from other tab?


#1

I have design app like this image

in detail page i wrote code

  ionViewWillEnter(){
    this.stack = [];
    for(let i = 0; i < this.navCtrl.length(); i++) {
      let view = this.navCtrl.getByIndex(i);
      this.stack.push({
        page: view.component.name,
        params: view.data
      });
    }
    this.storage.set("stackPage", this.stack); //save stack to storage
 }

then i call stack from TAB 2 use function goToStack()

goToStack(stack){
 this.storage.get('stackpage').then(val=>{
   this.navCtrl.insertPages(1, val);
 });
}

but active tab is TAB 2 i want active tab in TAB 1

can anyone help me to set active tab in TAB 1?


#2

See: https://ionicframework.com/docs/api/components/tabs/Tabs/

switchTabs() {
  this.navCtrl.parent.select(0);
}

#3

but when TAB 1 on the root, stack page will be on the root too


#4

Each tab has it’s own page stack.


#5

what if TAB 1 is list of book, then book have some table of content and content. in TAB 2 i want to set user activity like last view, bookmark etc.


#6

If you have access to the navCtrl then you have access to each tabs page stack.