Skip to content

Commit 445b96a

Browse files
author
vakrilov
committed
feat(router): detach change detection on navigation
1 parent 29f2b2f commit 445b96a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Diff for: e2e/router/app/first/first.component.ts

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export class FirstComponent implements OnInit, OnDestroy {
3636
console.log("FirstComponent - ngOnDestroy()");
3737
}
3838

39+
ngDoCheck() {
40+
console.log("FirstComponent - ngDoCheck()");
41+
}
42+
43+
ngOnChanges(){
44+
console.log("FirstComponent - ngOnChanges()");
45+
}
46+
3947
goBack() {
4048
this.message = "";
4149
if (this.routerExt.canGoBack()) {

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
175175

176176
deactivate(): void {
177177
if (!this.locationStrategy._isPageNavigatingBack()) {
178-
log("Currently not in page back navigation - component should be detached instead of deactivated.");
179-
return;
178+
log("Currently not in page back navigation - component should be detached instead of deactivated.");
179+
return;
180180
}
181181

182182
log("PageRouterOutlet.deactivate() while going back - should destroy");
@@ -205,6 +205,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
205205

206206
log("PageRouterOutlet.detach() - " + routeToString(this._activatedRoute));
207207

208+
// Detach from ChangeDetection
209+
this.activated.hostView.detach();
210+
208211
const component = this.activated;
209212
this.activated = null;
210213
this._activatedRoute = null;
@@ -218,6 +221,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
218221
log("PageRouterOutlet.attach() - " + routeToString(activatedRoute));
219222

220223
this.activated = ref;
224+
225+
// reattach to ChangeDetection
226+
this.activated.hostView.reattach();
221227
this._activatedRoute = activatedRoute;
222228

223229
this.markActivatedRoute(activatedRoute);

0 commit comments

Comments
 (0)