离子后退按钮与手动触发$ ionicHistory.goBack()的行为不同

时间:2016-05-15 17:33:28

标签: ionic-framework angular-ui-router

当我尝试从

导航时

main.adminmain.admin.emergencyDetailmain.admin.emergencyDetail.photos

回到左上角的正常后退按钮,然后我到

main.admin

但是当我在main.admin.emergencyDetail.photos状态上使用时:

$timeout(function () {
  $ionicHistory.goBack();
}, 5000)

然后我按照你期望的main.admin.emergencyDetail(我最终想要的)得到。这里的问题在哪里?

app.js:

      $stateProvider
  // this state is placed in the <ion-nav-view> in the index.html
    .state('main', {
      url: '/main',
      abstract: true,
      templateUrl: 'main/templates/menu.html',
      controller: 'MenuCtrl as menu'
    })
    .state('main.inactive', {
      url: '/inactive',
      views: {
        'pageContent': {
          templateUrl: 'main/templates/inactive.html',
          controller: 'InactiveCtrl as inactive'
        }
      }
    })
    .state('main.profile', {
      url: '/profile',
      views: {
        'pageContent': {
          templateUrl: 'main/templates/profile.html',
          controller: 'ProfileCtrl as profile'
        }
      }
    })
    .state('main.active', {
      url: '/active',
      views: {
        'pageContent': {
          templateUrl: 'main/templates/active.html',
          controller: 'ActiveCtrl as active'
        }
      }
    })
    .state('main.admin', {
      url: '/admin',
      views: {
        'pageContent': {
          templateUrl: 'main/templates/admin.html',
          controller: 'AdminCtrl as admin'
        }
      }
    })
    .state('main.admin.settings', {
      url: '/settings',
      views: {
        'pageContent@main': {
          templateUrl: 'main/templates/admin-settings.html',
          controller: 'AdminSettingsCtrl as adminsettings'
        }
      }
    })
    .state('main.admin.registration', {
      url: '/registration',
      views: {
        'pageContent@main': {
          templateUrl: 'main/templates/admin-registration.html',
          controller: 'AdminRegistrationCtrl as adminregistration'
        }
      }
    })
    .state('main.admin.activePupils', {
      url: '/active/pupils',
      views: {
        'pageContent@main': {
          templateUrl: 'main/templates/pupils-active.html',
          controller: 'PupilsActiveCtrl as pupilsactive'
        }
      }
    })
    .state('main.admin.activeAdmins', {
      url: '/active/admins',
      views: {
        'pageContent@main': {
          templateUrl: 'main/templates/admin-active.html',
          controller: 'AdminActiveCtrl as adminactive'
        }
      }
    })
    .state('main.admin.emergencyDetail', {
      url: '/emergency/:id',
      views: {
        'pageContent@main': {
          templateUrl: 'main/templates/admin-emergency-detail.html',
          controller: 'AdminEmergencyCtrl as adminemergency'
        }
      }
    })
    .state('main.admin.emergencyDetail.photos', {
      url: '/photos',
      views: {
        'pageContent@main': {
          templateUrl: 'main/templates/admin-emergency-photos.html',
          controller: 'AdminEmergencyCtrl as adminemergency'
        }
      }
    });
  $urlRouterProvider.otherwise('/main/inactive');

我对两个视图使用相同的Controller(在那里写但可能很重要)。

这里是照片中日志的屏幕截图:

enter image description here

1 个答案:

答案 0 :(得分:0)

经过长时间的回收,我发现.config中的以下提供程序帮助了:$mdGestureProvider.skipClickHijack();

这解决了多个问题(以及$ ionicPopup两次射击)。