Ionic framework 如何导航到NavController子页面的同级页面?
我有一个Ionic framework 如何导航到NavController子页面的同级页面?,ionic-framework,ionic2,Ionic Framework,Ionic2,我有一个离子列表,其中的项目导致: 子页面A 子页面B 子页面C 在子页面B上时,我希望导航到上一页(子页面A)和下一页(子页面C),同时保持返回按钮以返回父页面 iOS中的邮件应用程序就是一个例子。当您查看邮件时,它会为您提供上下箭头以移动到上一封/下一封邮件 我在文档中找不到任何描述这种行为的内容 注意,这是为ionic2标记的此子导航条 <ion-nav-bar class="bar-light"> <ion-nav-buttons side="left"&g
离子列表
,其中的项目导致:
- 子页面A
- 子页面B
- 子页面C
<ion-nav-bar class="bar-light">
<ion-nav-buttons side="left">
<i class="button button-clear button-positive icon ion-android-arrow-back" ng-click="goParent();"></i>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button type="submit" class="button button-positive button-clear icon ion-arrow-up-b" ng-click="goPrevious()"></button>
</ion-nav-buttons>
<ion-nav-buttons side="secondary">
<button type="submit"class="button button-positive button-clear icon ion-arrow-down-b" ng-click="goNext()"></button>
</ion-nav-buttons>
</ion-nav-bar>
这是controller.js
.controller('ChildCtrl', function ($stateParams, $location, $scope) {
$scope.URL = {};
$scope.URL.Parent = "parent"
$scope.goParent = function () {
$location.url($scope.URL.Parent);
};
$scope.Previous = $stateParams.mailSerialNumber - 1;
$scope.URL.Previous = "parent/child/" + $scope.Previous;
$scope.goPrevious = function () {
$location.url($scope.URL.Previous);
};
$scope.Next = $stateParams.mailSerialNumber + 1;
$scope.URL.Next = "parent/child/" + $scope.Next;
$scope.goNext = function () {
$location.url($scope.URL.Next);
};
})
我今天遇到了完全相同的问题,并通过以下方式解决了它:
// Push the sibling page onto the stack.
this.navCtrl.push( PageToPush, { fooParam : 'bar' } ).then( ()=> {
// There should be 3 pages in the stack now, and we need to remove the 2nd page (index 1)
this.navCtrl.remove(1);
}
其中this.navCtrl
是NavController
的一个实例。这是假设您总是从根页面导航,并且希望在堆栈中只保留一个子页面。这样做的目的是将新页面推送到堆栈上(即堆栈中的索引2),然后在推送页面后,从堆栈中删除索引1页面
希望有帮助 谢谢。但问题是离子2。
// Push the sibling page onto the stack.
this.navCtrl.push( PageToPush, { fooParam : 'bar' } ).then( ()=> {
// There should be 3 pages in the stack now, and we need to remove the 2nd page (index 1)
this.navCtrl.remove(1);
}