离子导航后退按钮没有显示

时间:2016-11-02 03:50:30

标签: angularjs ionic-framework angular-ui-router ionic-view

我已将此代码添加到我的index.html

<ion-nav-bar class="bar-positive">
  <ion-nav-back-button></ion-nav-back-button>
</ion-nav-bar>

但后面的按钮没有显示。我也尝试了将此代码放在index.html中的替代方法

<ion-nav-bar ng-controller="MyCtrl">
 <ion-nav-back-button class="button-clear"
  ng-click="myGoBack()">
   <i class="ion-arrow-left-c"></i> Back
 </ion-nav-back-button>
</ion-nav-bar>

,这在app.js

.controller('listController',['$scope','$http','$state','$ionicHistory',
 function($scope, $http, $state, $ionicHistory){
 $scope.myGoBack = function() {
 $ionicHistory.goBack();
 };

仍未显示。

2 个答案:

答案 0 :(得分:0)

这对我有用:

<body ng-controller='mainCtrl as ctrl'>
<ion-nav-bar class="mainBar">
    <ion-nav-back-button>
    </ion-nav-back-button>
    <ion-nav-buttons side="left">
        <a class="button button-icon">
             <i class="icon ion-navicon"></i>
        </a>
    </ion-nav-buttons>
    <ion-nav-buttons side="right">
      <a class="button button-icon icon" ng-click="ctrl.goMain();">
             <i class="icon ion-android-home"></i>
      </a>
      <a class="button button-icon icon" ng-click="ctrl.goProfile();">
             <i class="icon ion-android-person" ></i>
      </a>
      <a class="button button-icon icon" ng-click="ctrl.goCustomCmd();">
             <i class="icon ion-android-search"></i>
      </a>
    </ion-nav-buttons>
</ion-nav-bar>

<ion-nav-view></ion-nav-view>    

另请检查$stateProvider配置是否正确。希望有所帮助。

答案 1 :(得分:0)

尝试使用

$scope.$on('$ionicView.beforeEnter', function(event, viewData) {
        viewData.enableBack = true;
    });

控制器内部,即明确提示后退按钮