Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

Tab + Normal View -> Bug on back button

$
0
0

@GabrielMorin wrote:

Hello,

I'm trying to make a simple app with ionic, but the navigation part is giving me the worst time.
I have 4 tabs, and a setting button in the nav-bar that's supposed to open a new view (not nested in the tab) to show the user's settings.
My problem is: when I go to settings and then I press back, it works in the nav-bar, but not in the content view.
Meaning, I see that the nav-bar goes back to the previous state, but the content view stays the same.

As the back button was not showing on the settings view, i used:
$scope.$on('$ionicView.beforeEnter', function (event, viewData) {
viewData.enableBack = true;
});
Maybe it comes from this... Maybe if I have to force show this button I made something wrong before in the code structure.

here is an extract of the index.html:

  <body ng-app="starter" ng-controller="MainCtrl">
    <!--
      The nav bar that will be updated as we navigate between views.
    -->
    <ion-nav-bar class="bar-stable">
      <ion-nav-back-button>
      </ion-nav-back-button>
      <ion-nav-buttons side="right">
        <button class="button button-clear" ui-sref="settings" nav-direction="forward">
          <i class="icon ion-ios-gear"></i>
        </button>
      </ion-nav-buttons>
    </ion-nav-bar>

    <!--
      The views will be rendered in the <ion-nav-view> directive below
      Templates are in the /templates folder (but you could also
      have templates inline in this html file if you'd like).
    -->
    <ion-nav-view>

    </ion-nav-view>
    <ion-nav-view name="settings" view-title="Settings"></ion-nav-view>

  </body>

The complete settings.html:

  <ion-view name="settings" view-title="Settings">
    <ion-nav-bar class="bar-stable">
      <ion-nav-back-button />
    </ion-nav-bar>
    <ion-content class="padding">
      <h2>Use the settings to set some stuff up</h2>
    </ion-content>
  </ion-view>

The states in app.js:

$stateProvider

// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})

// Each tab has its own nav history stack:

.state('tab.news', {
  url: '/news',
  views: {
    'tab-news': {
      templateUrl: 'templates/tab-news.html',
      controller: 'NewsCtrl'
    }
  }
})

[...] other tab states [...]

.state('settings', {
  url: '/settings',
  views: {
    'settings': {
      templateUrl: 'templates/settings.html',
      controller: 'SettingsCtrl'
    }
  }
});

This "nearly working" state is really driving me crazy, could you give me a hand on this?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>