简体   繁体   中英

ionic nav-bar title doesn't show

I started learning ionic with angularjs. I have a problem with the title on the screen. It is in the code but didn't shown in browser when running in localhost or either on mobile. The navbar is there with the specific template but the title no. Thanks for the help. Sorry for the badly embed codes :|

angular.module("veganApp", ["ionic"])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
})

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

  $stateProvider

    .state('home', {
      url: "/home",
      templateUrl: "app/home/home.html"
    });

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/home');
  });

<!-- begin snippet: js hide: false -->
<ion-nav-bar class="bar-balanced">
    <h1 class="title">Meal Plan</h1>
</ion-nav-bar>

<ion-tabs class="tabs-balanced tabs-icon-top">
    <ion-tab title="Meal Plan" icon="ion-ios-list-outline" href="#">
        <ion-view></ion-view>
    </ion-tab>

    <ion-tab title="Shopping List" icon="ion-ios-cart-outline" href="#">
        <ion-view></ion-view>
    </ion-tab>
</ion-tabs>

It works for me if I set the nav-bar in index.html like this:

 <body ng-app="yourApp"> <ion-nav-bar class="bar-stable"> <ion-nav-back-button> </ion-nav-back-button> </ion-nav-bar> <ion-nav-view></ion-nav-view> </body> 

I don't know why your solution doesn't work but as long as you dont need to hide the nav-bar somewhere it works this way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM