【发布时间】:2016-11-06 22:03:21
【问题描述】:
我有一个具有以下 ui-router 设置的 ionic 应用程序,其中 locations 状态是 map 和 favourites 2 个状态的父级。 updates 状态是一种可以从任何状态访问的详细信息页面。
.state('locations', {
abstract: false,
cache: true,
url: '/locations',
templateUrl: 'templates/locations.html',
controller: 'LocationsCtrl'
})
.state('locations.favourites', {
cache: true,
url: '/favourites',
templateUrl: 'templates/locations.favourites.html',
controller: 'LocationsFavouritesCtrl'
})
.state('locations.map', {
cache: true,
url: '/map',
templateUrl: 'templates/locations.map.html',
controller: 'LocationsMapCtrl'
})
.state('updates', {
cache: true,
url: '/updates/:place_id',
templateUrl: 'templates/updates.html',
controller: 'UpdatesCtrl',
params: {'place_id': 'undefined'}
})
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/locations/map');
这是 HTML
<body ng-app="app" animation="slide-left-right-ios7">
<div>
<div>
<ion-nav-bar class="bar-turq">
<ion-nav-back-button class="button-icon icon ion-ios-arrow-back light"></ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view></ion-nav-view>
</div>
</div>
除了“更新”状态下的后退按钮总是返回到locations.map 而不是记住以前的状态之外,这非常有效,即我可能来自locations.favourites。我的设置是否存在根本性问题?
**
- 更新:
**
好的,所以在 UpdatesCtrl 里面我添加了这段代码来检查视图历史,无论我从哪里访问 /updates 视图,后视图都是 location.map
$scope.$on('$ionicView.enter', function() {
console.log($ionicHistory.viewHistory());
}
【问题讨论】:
标签: angularjs ionic-framework angular-ui-router state