fix(angular): router-outlet memory leak

fixes #16285
This commit is contained in:
Manu Mtz.-Almeida
2018-12-19 00:43:45 +01:00
committed by Manu MA
parent d1cecf142b
commit 2c41823676
4 changed files with 15 additions and 13 deletions

View File

@ -2,6 +2,7 @@ import { ComponentRef, NgZone } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { RouterDirection } from '@ionic/core';
import { bindLifecycleEvents } from '../../providers/angular-delegate';
import { NavController } from '../../providers/nav-controller';
import { RouteView, computeStackId, destroyView, getUrl, insertView, isTabSwitch, toSegments } from './stack-utils';
@ -26,13 +27,16 @@ export class StackController {
this.tabsPrefix = tabsPrefix !== undefined ? toSegments(tabsPrefix) : undefined;
}
createView(enteringRef: ComponentRef<any>, activatedRoute: ActivatedRoute): RouteView {
createView(ref: ComponentRef<any>, activatedRoute: ActivatedRoute): RouteView {
const url = getUrl(this.router, activatedRoute);
const element = (ref && ref.location && ref.location.nativeElement) as HTMLElement;
const unlistenEvents = bindLifecycleEvents(ref.instance, element);
return {
id: this.nextId++,
ref: enteringRef,
element: (enteringRef && enteringRef.location && enteringRef.location.nativeElement) as HTMLElement,
stackId: computeStackId(this.tabsPrefix, url),
unlistenEvents,
element,
ref,
url,
};
}