distante
distante

Reputation: 7005

hide menu button on specific view without hiding navbar (ionic)

There are similar question but not this exact one. I have this structure in an ionic app view

<ion-view>
<ion-nav-title>
    <a id="go_to_app" href="#startseite">
        <span class="ion-android-exit"></span>
    </a>

    <img src="img/logo_header.png">

</ion-nav-title>
<ion-content class="star-wrap">
.
. contents
.
</ion-content class="star-wrap">

What I'm trying to achieve is show the ion-android-exit button instead of the menu button in this specific view.

Is this possible?

Upvotes: 1

Views: 336

Answers (2)

Dinesh Devkota
Dinesh Devkota

Reputation: 1417

You need to use ng-if like in example here. http://codepen.io/anon/pen/AXkJGa after setting the value of ng conditional to true in the controller.

Example HTML

    <title>Ionic Modal</title>
  <body ng-controller="State1Ctrl">

   <ion-nav-bar>
    <ion-nav-view>
      <ion-view>
        <ion-nav-title>
          <a id="go_to_app" href="#startseite">
        <span class="ion-android-exit" ng-if="!hidethisview"></span>
    </a>
        </ion-nav-title>
        <ion-content>
          Some super content here!
        </ion-content>
      </ion-view>
    </ion-nav-view>
      </ion-nav-bar>

And JS

angular.module('ionicApp', ['ionic'])
.controller('State1Ctrl', function($scope, $state) {
if($state.current.name=="")// you need to have your state name inside quotes
//this example don't have one
{
  $scope.hidethisview=true;
}

});

Upvotes: 0

distante
distante

Reputation: 7005

There was a (way) easy and simple way to do this.

Adding <ion-nav-buttons></ion-nav-buttons> inside <ion-view></ion-view> will rewrite the menu button with whatever I want, or just hide it with no contents.

Upvotes: 1

Related Questions