Ionic Angular JS导航项未导航

Ionic Angular JS navigation item not navigating

本文关键字:导航 JS Angular Ionic      更新时间:2023-09-26

我的应用程序中目前有其他页面导航良好,但我添加了一个新的选项卡,当我单击它时,它只是关闭菜单,而不是转到页面。我不知道为什么。。。有人看见了吗?

app.js:

 .state('utab.history', {
    url: '/history',
    views: {
      'utab-login': {
        templateUrl: 'templates/history.html',
        controller: 'HistoryCtrl'
      }
    }
  })

控制器:

 $scope.historyClick=function(){
        console.log("historyClick");
        $state.go('utab.history');
    };
.controller('HistoryCtrl', function($scope,$state,AppServer,AppHelper,AppStorage,$http) {
    alert("yo2");
})

导航中的html代码:

<ion-item class="item-icon-left" nav-clear="" menu-close="" ui-sref="utab.history" ng-click="historyClick()">
          <i class="icon ion-document"></i>
          <h2 class="menu-text">History</h2>
        </ion-item>

有什么想法吗?

您可能有一些冲突。

两个菜单关闭,用户界面关闭,点击可能都在监听点击事件。如果菜单关闭后取消了事件处理,你就完蛋了。

尝试ng-click="historyClick($event)"并删除菜单关闭和ui sref,这样您就可以尝试从$event中获取项目,以便关闭菜单并进行导航。

另一种可能性是:将每个指令拆分成单独的DOM元素来处理点击,我认为菜单关闭的级别更高。