feat(angular): add global pop() (#17182)

fixes #16340
This commit is contained in:
Manu MA
2019-01-21 01:52:47 +01:00
committed by GitHub
parent 25b88478a1
commit 766c79d2a1
7 changed files with 35 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import { Attribute, ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, Directive, ElementRef, EventEmitter, Injector, NgZone, OnDestroy, OnInit, Optional, Output, ViewContainerRef } from '@angular/core';
import { Attribute, ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, Directive, ElementRef, EventEmitter, Injector, NgZone, OnDestroy, OnInit, Optional, Output, SkipSelf, ViewContainerRef } from '@angular/core';
import { ActivatedRoute, ChildrenOutletContexts, OutletContext, PRIMARY_OUTLET, Router } from '@angular/router';
import { Config } from '../../providers/config';
@ -51,11 +51,12 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
@Optional() @Attribute('tabs') tabs: string,
private changeDetector: ChangeDetectorRef,
private config: Config,
navCtrl: NavController,
private navCtrl: NavController,
elementRef: ElementRef,
router: Router,
zone: NgZone,
activatedRoute: ActivatedRoute
activatedRoute: ActivatedRoute,
@SkipSelf() @Optional() readonly parentOutlet?: IonRouterOutlet
) {
this.nativeEl = elementRef.nativeElement;
this.name = name || PRIMARY_OUTLET;
@ -175,6 +176,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
this.activatedView = enteringView;
this.stackCtrl.setActive(enteringView).then(data => {
this.navCtrl.setTopOutlet(this);
this.activateEvents.emit(cmpRef.instance);
this.stackEvents.emit(data);
});

View File

@ -76,8 +76,11 @@ export class StackController {
pop(deep: number, stackId = this.getActiveStackId()) {
return this.zone.run(() => {
const views = this.getStack(stackId);
if (views.length <= deep) {
return Promise.resolve(false);
}
const view = views[views.length - deep - 1];
return this.navCtrl.navigateBack(view.url);
return this.navCtrl.navigateBack(view.url).then(() => true);
});
}