Open an ion-tab from a custom javascript

Hi,

I have a an ion-tabs on 2 tabs. On the second tab, I have a button. I would like the click on this button to open the first tab.

How can I achieve that ?

Regards,

St.

Just found the solution:

http://ionicframework.com/docs/api/service/$ionicTabsDelegate/

function MyCtrl($scope, $ionicTabsDelegate) {
$scope.selectTabWithIndex = function(index) {
$ionicTabsDelegate.select(index);
}
}