How to select first tab by default?


#1

I’m using tabs with no state(when I navigate one to other the url does not change) and I want the first tab selected by default.

<ion-tabs class="tabs-icon-top tabs-color-active-positive">
  <!-- Dashboard Tab -->
  <ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/dash">
    <ion-nav-view name="tab-dash"></ion-nav-view>
  </ion-tab>

  <!-- Chats Tab -->
  <ion-tab title="Chats" icon-off="ion-ios-chatboxes-outline" icon-on="ion-ios-chatboxes" href="#/tab/chats">
    <ion-nav-view name="tab-chats"></ion-nav-view>
  </ion-tab>

  <!-- Account Tab -->
  <ion-tab title="Account" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tab/account">
    <ion-nav-view name="tab-account"></ion-nav-view>
  </ion-tab>
</ion-tabs>

js:

.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider

      .state('main', {
        url: '/main',
        abstract: true,
        templateUrl: 'templates/main.html'
      })
      .state("main.tabs", {
        url: "/x",
        views: {
          "tab-dash": {
            templateUrl: "templates/tab-dash.html",
          },
          "tab-account": {
            templateUrl: "templates/tab-account.html",
          },
          "tab-chats": {
            templateUrl: "templates/tab-chats.html",
          }
        }
      });

    $urlRouterProvider.otherwise('/main/x');
  });

When I run this code, the last tab is selected by default… how can I change that?


#2

If I comment all <ion-nav-view> it works !!!