user1715408
user1715408

Reputation:

How to nest ion-side-menus into ion-nav-view?

I'm getting started with Ionic Framework development.

I started a basic tabs app with 3 tabs: Map, Settings and About.

I have the following in my index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/ionic.app.css" rel="stylesheet">

    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
  </head>
  <body ng-app="starter" animation="slide-left-right-ios7">
    <!-- 
    The nav bar that will be updated as we navigate between views.
    -->
    <ion-nav-bar class="bar-stable nav-title-slide-ios7">
    <ion-nav-back-button class="button-icon icon  ion-ios7-arrow-back">
      Back
    </ion-nav-back-button>
    </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>
  </body>
</html>

As I've understood, the views inside the /template directory are rendered inside the <ion-nav-view>

All these templates start with ion-view. Unless the First tab (MAP, (templates/tab-map.html) which I customized to use a ion-side-menus and looks like this:

<ion-side-menus>
  <ion-side-menu-content>
    <ion-header-bar class="bar-positive">
      <div class="buttons">
        <button class="button icon button-clear ion-navicon-round" ng-click="toggleLeft()">
        </button>
      </div>
      <h1 class="title">Mapa</h1>
    </ion-header-bar>
  </ion-side-menu-content>
  <ion-side-menu side="left">
    <header class="bar bar-header bar-assertive">
      <div class="title">Categorias</div>
    </header>
    <ion-list class="Padding">
      <ion-item ng-repeat="cat in categories" type="item-text-wrap">
        {{ cat.name }}
      </ion-item>
    </ion-list>
  </ion-side-menu>
</ion-side-menus>

Ionic Side Menu For Map Tab

For example, the About tab starts with ion-view which is supposed to be nested perfectly into the <ion-nav-view> in the index.html file shown above as the view tag is a child of the nav-view tag.

About tab (templates/tab-about.html):

<ion-view title="About">
  <ion-content>
    <h1>Some indystry Inc.</h1>
  </ion-content>
</ion-view>

When I click the about tab ("Acerca de") It creates a view like this

About Tab

I can switch easily from the settings and about tab but when I switch back to the MAP view something obviously goes wrong:

Error

It should show the map view with the side menu but it just keeps the 'about' title and no content, I have to refresh the page in order to fix this behaviour.

Can anyone tell me the aproppiate way of making this map tab be rendered when I switch back to it without manually refreshing the page?

Thanks in advance.

Upvotes: 4

Views: 5746

Answers (1)

user1715408
user1715408

Reputation:

Turns out that you can't nest an ion-side-menu into an ion-tab, doing it in reverse worked, I just had to place the button in the map tab and disable it for the other tabs.

Upvotes: 1

Related Questions