File tree 2 files changed +22
-3
lines changed
2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {
33
33
on ,
34
34
launchEvent ,
35
35
LaunchEventData ,
36
+ exitEvent ,
36
37
} from "tns-core-modules/application" ;
37
38
import { TextView } from "tns-core-modules/ui/text-view" ;
38
39
@@ -255,7 +256,16 @@ export class NativeScriptPlatformRef extends PlatformRef {
255
256
args . root = rootContent ;
256
257
}
257
258
) ;
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
+ ) ;
258
267
on ( launchEvent , launchCallback ) ;
268
+ on ( exitEvent , exitCallback ) ;
259
269
260
270
applicationRun ( ) ;
261
271
}
Original file line number Diff line number Diff line change @@ -352,12 +352,19 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
352
352
// Add it to the new page
353
353
page . content = componentView ;
354
354
355
- page . on ( Page . navigatedFromEvent , ( < any > global ) . Zone . current . wrap ( ( args : NavigatedData ) => {
355
+ const navigatedFromCallback = ( < any > global ) . Zone . current . wrap ( ( args : NavigatedData ) => {
356
356
if ( args . isBackNavigation ) {
357
357
this . locationStrategy . _beginBackPageNavigation ( this . frame ) ;
358
358
this . locationStrategy . back ( null , this . frame ) ;
359
359
}
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
+ } ) ;
361
368
362
369
const navOptions = this . locationStrategy . _beginPageNavigation ( this . frame ) ;
363
370
@@ -374,7 +381,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire
374
381
}
375
382
376
383
this . frame . navigate ( {
377
- create : ( ) => { return page ; } ,
384
+ create ( ) {
385
+ return page ;
386
+ } ,
378
387
clearHistory : navOptions . clearHistory ,
379
388
animated : navOptions . animated ,
380
389
transition : navOptions . transition
You can’t perform that action at this time.
0 commit comments