In my Tabs component I added some tabs dynamically and now I need to know which number of tab has been selected by the user to provide the needed content. I tried the following:
<ion-tabs> <ion-tab *ngFor="let tab of tabs" [tabTitle]="tab.title" [tabIcon]="tab.icon" [root]="tab.root" (ionSelect)="setActualTabNumber(tab.index)"></ion-tab> </ion-tabs>
The call of setActualTabNumber(tab.index) is setting the index of the actual tab to a variable. It is working like I want to, but its too late. Until it is set, the content of the tab is created with the last value of the index. Therefore the content is always a value of the index back, e.g. if the index is 2 it is shown the content of index 1.
I think this is a problem of async code, but I don’t know to solve it. Can you help me? Thanks in advance.