From ba0a041e86747f23f6e12bafaa932e39bb0c2135 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 21 Jan 2016 16:32:59 -0600 Subject: [PATCH] fix(NavController): check if view has already been destroyed --- ionic/components/nav/nav-controller.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 2ca22392ab..efd0f5e980 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -1187,7 +1187,7 @@ export class NavController extends Ion { // remove the page from its container let index = viewContainer.indexOf(hostViewRef); - if (index !== -1) { + if (!hostViewRef.destroyed && index !== -1) { viewContainer.remove(index); } }); @@ -1205,11 +1205,11 @@ export class NavController extends Ion { let navbarTemplateRef = view.getNavbarTemplateRef(); if (navbarContainerRef && navbarTemplateRef) { - let navbarView = navbarContainerRef.createEmbeddedView(navbarTemplateRef); + let navbarViewRef = navbarContainerRef.createEmbeddedView(navbarTemplateRef); view.addDestroy(() => { - let index = navbarContainerRef.indexOf(navbarView); - if (index > -1) { + let index = navbarContainerRef.indexOf(navbarViewRef); + if (!navbarViewRef.destroyed && index > -1) { navbarContainerRef.remove(index); } });