On button click navigate to the specific tab in another page

#1

I have 2 pages, service.html & sevicetab.html. Data is fetched by api in both pages. When i click on one of the categories in the service.html page, i want the same category to be highlighted / selected in the servicetab.html page. Can someone please guide me to achieve this.


To be precise this pic shows what i am trying to achieve…

#2

Which component did you use?
If you used ion-segment set value in ngModel for segments. If you used super-tabs, set selected index to the index you want to get selected.
try writing this logic in ionViewWillEnter()

#3

I have used ion-segment

#4

For ion-segment, set value of ion-segment ngModel in ionViewWillEnter.
for ex. in HTML

<ion-segment [(ngModel)]="segments">
  <ion-segment-button value="0">
    <ion-label>First</ion-label>
  </ion-segment-button>
  <ion-segment-button value="1">
    <ion-label>Second</ion-label>
  </ion-segment-button>
</ion-segment>

in TS file,

ionViewWillEnter() {
  this.segments = navParams.get('activeTab');
}

while navigating to page, send index in navParams.

goTo(index) {
  this.navCtrl.push(TabsPage, { activeTab : index });
}
#5

How to do this on button click… as Service.html page has buttons

#6

Implement this code on button click

#7

this will be on tabs page

#8

Work like a charm. Thank you very much…