javascript - 如何在 Ionic 中获取事件选项卡

标签 javascript angularjs ionic-framework

我在模态中有标签,代码如下:

<ion-tabs class="tabs-positive tabs-top">

<ion-tab title="FIND">
<ion-view>
<ion-content>
<div class="list list-inset">
  <label class="item item-input">
    <i class="icon ion-search placeholder-icon"></i>
    <input type="text" ng-model="data.sight" placeholder="Find events or people" ng-change="searchSight()">
  </label>
</div>
</ion-content>
</ion-view>
</ion-tab>
<ion-tab>
   ... More tabs
</ion-tab>
</ion-tabs>

我有一个页脚按钮,我想根据事件选项卡执行特定操作,如何在 Ionic 中获取事件选项卡?

非常感谢!

最佳答案

您可以使用 $ionicTabsDelegate 获取选项卡的选定索引,这可能会帮助您确定要采取的操作。

function MyCtrl($scope, $ionicTabsDelegate) {
         if ($ionicTabsDelegate.selectedIndex() == 0){
     // Perform some action 
    }
}

使用 $getByHandle 方法控制特定的 ionTabs 实例。

示例:

$ionicTabsDelegate.$getByHandle('my-handle').selectedIndex();

$ionicTabsDelegate API Documentation 中有更详细的解释

关于javascript - 如何在 Ionic 中获取事件选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31278816/

相关文章:

angular - 找不到管道 'translate' 错误在 Ionic 4 中显示

javascript - 使用 d3.nest() 中的嵌套数据创建圆环图

javascript - 优化渲染 React Components 依赖于 props

angularjs - 使用 HTML5 indexedDB 存储多个对象

AngularJS 'ng-filter' 在约 1000 个元素的数组上非常慢

javascript - 不使用路由的 Angular 重新加载模板 + Controller

angularjs - 动态创建的指令属性在 AngularJS 的 ng-repeat 中不起作用

javascript - Ionic/Angular $urlRouterProvider.otherwise 问题

javascript - 在 Deno 中使用 linter/linting 工具

javascript - 如何将网页的固定宽高设置为所用屏幕的最大宽高?