How to make the latest added tab active


hi! I am adding tabs dynamically like this demo
The issue is I want that the newly added tab must be active. Right now only first tab is active and I have to tap the new tab to active.
Please help me how to nonactive the previous active tab and make active the newly added tab.



Hey there,$ionicTabsDelegate/
You can find a method called “select” where you can select a tab.
If you add a tab -> call that select method and activate your created tab :wink:

Greetz, bengtler


you could use $
but there is a problem when you call it immediately after .tabs.push, it throws an error
coze at this time the tab does not yet exists.

therefore i used a little trick and added $timeout with a delay of 50 ms (maybe even lower would work)

the only thing you have to do is track the index of the newly pushed Tab (push reürns not the exact index!)
here my tests:


@bengtler @Auro thank you :blush:


Ha, a little late to the conversation but, yes $ is the way to go. Thanks @Auro and @bengtler for helping out!