File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {
3333 on ,
3434 launchEvent ,
3535 LaunchEventData ,
36+ exitEvent ,
3637} from "tns-core-modules/application" ;
3738import { TextView } from "tns-core-modules/ui/text-view" ;
3839
@@ -255,7 +256,16 @@ export class NativeScriptPlatformRef extends PlatformRef {
255256 args . root = rootContent ;
256257 }
257258 ) ;
259+ const exitCallback = profile (
260+ "nativescript-angular/platform-common.exitCallback" , ( ) => {
261+ const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule . get ( ) : null ;
262+ if ( lastModuleRef ) {
263+ lastModuleRef . destroy ( ) ;
264+ }
265+ }
266+ ) ;
258267 on ( launchEvent , launchCallback ) ;
268+ on ( exitEvent , exitCallback ) ;
259269
260270 applicationRun ( ) ;
261271 }
Original file line number Diff line number Diff line change @@ -352,12 +352,19 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
352352 // Add it to the new page
353353 page . content = componentView ;
354354
355- page . on ( Page . navigatedFromEvent , ( < any > global ) . Zone . current . wrap ( ( args : NavigatedData ) => {
355+ const navigatedFromCallback = ( < any > global ) . Zone . current . wrap ( ( args : NavigatedData ) => {
356356 if ( args . isBackNavigation ) {
357357 this . locationStrategy . _beginBackPageNavigation ( this . frame ) ;
358358 this . locationStrategy . back ( null , this . frame ) ;
359359 }
360- } ) ) ;
360+ } ) ;
361+ page . on ( Page . navigatedFromEvent , navigatedFromCallback ) ;
362+ componentRef . onDestroy ( ( ) => {
363+ if ( page ) {
364+ page . off ( Page . navigatedFromEvent , navigatedFromCallback ) ;
365+ page = null ;
366+ }
367+ } ) ;
361368
362369 const navOptions = this . locationStrategy . _beginPageNavigation ( this . frame ) ;
363370
@@ -374,7 +381,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
374381 }
375382
376383 this . frame . navigate ( {
377- create : ( ) => { return page ; } ,
384+ create ( ) {
385+ return page ;
386+ } ,
378387 clearHistory : navOptions . clearHistory ,
379388 animated : navOptions . animated ,
380389 transition : navOptions . transition
You can’t perform that action at this time.
0 commit comments