0

I have five tabs in my app. All these tabs require an id stored in local storage. So I want to get this id from local storage on the tab-bar page and send it to all tabs as the user clicks on respective tabs.

I don't want to use query params as exposing id in url is not safe

Edit I have used the angular router's navigationExtras with click event and it is working. But I am not sure this is the best way to this.

<ion-tab-button tab="tab1" (click)="tab1()">
      <ion-icon name="triangle"></ion-icon>
      <ion-label>Tab 1</ion-label>
    </ion-tab-button>



  tab1(){
    let navigationextas : NavigationExtras ={
      state : {
        user : 2
      }      
    }

    this.router.navigate(['tabs/tab1'], navigationextas)
  }
pratik jaiswal
  • 1,855
  • 9
  • 27
  • 59

1 Answers1

0

Try using a shared service to set the id on click and populate the tabs

Troy Thompson II
  • 421
  • 1
  • 6
  • 12