fix(angular): URL based tabs

This commit is contained in:
Manu Mtz.-Almeida
2018-04-02 21:20:59 +02:00
parent 5878ad9587
commit 14fedb9a44
3 changed files with 19 additions and 8 deletions

View File

@ -23,7 +23,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
private parentContexts: ChildrenOutletContexts,
private location: ViewContainerRef,
private resolver: ComponentFactoryResolver,
elementRef: ElementRef,
private elementRef: ElementRef,
@Attribute('name') name: string,
@Optional() @Attribute('stack') stack: any,
private changeDetector: ChangeDetectorRef,
@ -142,6 +142,8 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
const direction = this.navCtrl.consumeDirection();
await this.stackCtrl.setActive(enteringView, direction);
this.activateEvents.emit(this.activated.instance);
emitEvent(this.elementRef.nativeElement);
}
canGoBack(deep = 1) {
@ -153,6 +155,15 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
}
}
function emitEvent(el: HTMLElement) {
console.log('ionRouterOutletActivated');
const event = new CustomEvent('ionRouterOutletActivated', {
bubbles: true,
cancelable: true,
});
el.dispatchEvent(event);
}
class OutletInjector implements Injector {
constructor(
private route: ActivatedRoute,

View File

@ -16,7 +16,7 @@ export class TabDelegate {
elementRef.nativeElement.delegate = angularDelegate.create(cfr, injector);
}
@HostListener('ionNavDidChange')
@HostListener('ionRouterOutletActivated', ['$event'])
async onNavChanged() {
const tab = this.elementRef.nativeElement as HTMLIonTabElement;
await tab.componentOnReady();