Skip to content

Commit be72b0b

Browse files
committed
revert(page-router-outlet): stop detaching when navigating away from page
1 parent 780967d commit be72b0b

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

Diff for: nativescript-angular/common/detached-loader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class DetachedLoader { // tslint:disable-line:component-class-suffix
4141
}
4242

4343
public detectChanges() {
44-
this.changeDetector.detectChanges();
44+
this.changeDetector.markForCheck();
4545
}
4646

4747
// TODO: change this API -- async promises not needed here anymore.

Diff for: nativescript-angular/router/page-router-outlet.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
Attribute, ComponentFactory, ComponentRef, Directive,
3-
ReflectiveInjector, ResolvedReflectiveProvider,
4-
ViewRef, ViewContainerRef,
3+
ReflectiveInjector, ResolvedReflectiveProvider, ViewContainerRef,
54
Inject, ComponentFactoryResolver, Injector
65
} from "@angular/core";
76
import { isPresent } from "../lang-facade";
@@ -62,7 +61,6 @@ export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
6261
private viewUtil: ViewUtil;
6362
private refCache: RefCache = new RefCache();
6463
private isInitialPage: boolean = true;
65-
private previousPagesViews: Array<ViewRef> = new Array();
6664
private detachedLoaderFactory: ComponentFactory<DetachedLoader>;
6765

6866
private currentActivatedComp: ComponentRef<any>;
@@ -154,16 +152,8 @@ export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
154152
this.currentActivatedRoute = activatedRoute;
155153

156154
if (this.locationStrategy._isPageNavigatingBack()) {
157-
if (this.previousPagesViews.length) {
158-
this.containerRef.insert(this.previousPagesViews.pop());
159-
}
160-
161155
this.activateOnGoBack(activatedRoute, outletMap);
162156
} else {
163-
if (this.containerRef.length) {
164-
this.previousPagesViews.push(this.containerRef.detach());
165-
}
166-
167157
this.activateOnGoForward(activatedRoute, providers, outletMap, resolver, injector);
168158
}
169159
}
@@ -206,11 +196,9 @@ export class PageRouterOutlet { // tslint:disable-line:directive-class-suffix
206196
[...providers, ...pageResolvedProvider], injector);
207197
const loaderRef = this.containerRef.createComponent(
208198
this.detachedLoaderFactory, this.containerRef.length, childInjector, []);
209-
210199
loaderRef.changeDetectorRef.detectChanges();
211200

212201
this.currentActivatedComp = loaderRef.instance.loadWithFactory(factory);
213-
214202
this.currentActivatedComp.changeDetectorRef.detectChanges();
215203

216204
this.loadComponentInPage(page, this.currentActivatedComp);

0 commit comments

Comments
 (0)