离子标签和侧面菜单历史记录

时间:2015-01-17 21:07:49

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

我想在侧边菜单应用中放置一个标签式视图,但只是在应用的某些视图中。在应用程序中,有以下状态结构:

|--- Login                (login: menuContent)
|--- Orders list          (app.orders: menuContent)
    |--- Description      (app.orderTabs.description: orderTabs-description)
    |--- Products         (app.orderTabs.products: orderTabs-products)
         |--- New product (app.orderTabs.products.newProduct: orderTabs-products)
|--- Alerts list          (app.alerts: menuContent)
    |--- Description      (app.alertTabs: alertTabs-description)
    |--- Settings         (app.alertTabs: alertTabs-settings)

成为每个条目| --- ViewTitle(状态:离子导航视图名称)

menu.html:

<ion-side-menus enable-menu-with-back-views="false">
  <ion-side-menu-content>
    <ion-nav-bar class="bar-stable">
      <ion-nav-back-button>
      </ion-nav-back-button>

      <ion-nav-buttons side="left">
        <button class="button button-icon button-clear ion-navicon" menu-toggle="left">
        </button>
      </ion-nav-buttons>      
    </ion-nav-bar>
    <ion-nav-view name="menuContent"></ion-nav-view>
  </ion-side-menu-content>

  <ion-side-menu side="left">
    <ion-header-bar class="bar-stable">
      <h1 class="title">Menu</h1>
    </ion-header-bar>
    <ion-content>
      <ion-list>
        <ion-item nav-clear menu-close href="#/app/orders">
          Orders list
        </ion-item>
        <ion-item nav-clear menu-close href="#/app/alerts">
          Alerts list
        </ion-item>
        <ion-item nav-clear menu-close ng-click="logout()">
          Logout
        </ion-item>
      </ion-list>
    </ion-content>
  </ion-side-menu>
</ion-side-menus>

orderTabs.html:

<ion-tabs class="tabs-icon-top tab-bar">

  <ion-tab title="Order" icon="icon ion-clipboard" href="#/app/orderTabs/{{ data.order.id }}/description">
    <ion-nav-view name="orderTabs-description"></ion-nav-view>
  </ion-tab>


  <!-- products Tab -->
  <ion-tab title="Products" icon="icon ion-checkmark-circled" href="#/app/orderTabs/{{ data.order.id }}/products" badge="data.badgeProducts" badge-style="badge-assertive">
    <ion-nav-view name="orderTabs-products"></ion-nav-view>
  </ion-tab>

</ion-tabs>

我希望能够从描述或产品返回订单列表,任何人都知道是否可能?

目前我实现了在orderTabs中显示后退按钮,但在创建离子选项卡视图时,历史记录已被清除。

从订单控制器列表:

  $scope.goToOrder = function gotToOrder(orderId) {
    $ionicViewSwitcher.nextDirection('forward');
    $ionicHistory.nextViewOptions({
      historyRoot: false
    });
    $state.go('app.orderTabs.order', {
      orderId: orderId
    });
  };

1 个答案:

答案 0 :(得分:0)

我遇到了和你一样的问题,在搜索之后我发现这实际上是由于标签视图有自己的历史记录,Ionic团队故意实现的,所以他们实际上并没有记录有标签的视图历史上的导航。看起来这不会很快得到解决,所以我最终创建了自己的修改标签实现。我基本上模仿选项卡的外观,然后使用ng-show控制显示的内容。

<div class="tabs-striped tabs-top">
    <div class="tab-nav tabs">
        <a class="tab-item"
               ng-class="{'tab-item-active': tabs.active == 'description'}"
               ng-click="tabs.active = 'description'">
            <span>Description</span>
        </a>
        <a class="tab-item"
               ng-class="{'tab-item-active': tabs.active == 'pending'}"
               ng-click="tabs.active = 'products'">
            <span>Products</span>
        </a>
    </div>
</div>