@@ -43,7 +43,11 @@ export class StackController {
43
43
44
44
getExistingView ( activatedRoute : ActivatedRoute ) : RouteView | undefined {
45
45
const activatedUrlKey = getUrl ( this . router , activatedRoute ) ;
46
- return this . views . find ( vw => vw . url === activatedUrlKey ) ;
46
+ const view = this . views . find ( vw => vw . url === activatedUrlKey ) ;
47
+ if ( view ) {
48
+ view . ref . changeDetectorRef . reattach ( ) ;
49
+ }
50
+ return view ;
47
51
}
48
52
49
53
async setActive ( enteringView : RouteView ) {
@@ -55,30 +59,35 @@ export class StackController {
55
59
}
56
60
this . insertView ( enteringView , direction ) ;
57
61
await this . transition ( enteringView , leavingView , animation , this . canGoBack ( 1 ) , false ) ;
58
- this . cleanup ( ) ;
62
+ requestAnimationFrame ( ( ) => this . cleanup ( ) ) ;
59
63
}
60
64
61
65
canGoBack ( deep : number , stackId = this . getActiveStackId ( ) ) : boolean {
62
66
return this . getStack ( stackId ) . length > deep ;
63
67
}
64
68
65
69
pop ( deep : number , stackId = this . getActiveStackId ( ) ) {
66
- this . zone . run ( ( ) => {
70
+ return this . zone . run ( ( ) => {
67
71
const views = this . getStack ( stackId ) ;
68
72
const view = views [ views . length - deep - 1 ] ;
69
- this . navCtrl . navigateBack ( view . url ) ;
73
+ return this . navCtrl . navigateBack ( view . url ) ;
70
74
} ) ;
71
75
}
72
76
73
- startBackTransition ( stackId = this . getActiveStackId ( ) ) {
74
- const views = this . getStack ( stackId ) ;
75
- this . transition (
76
- views [ views . length - 2 ] , // entering view
77
- views [ views . length - 1 ] , // leaving view
78
- 'back' ,
79
- true ,
80
- true
81
- ) ;
77
+ startBackTransition ( ) {
78
+ const leavingView = this . activeView ;
79
+ if ( leavingView ) {
80
+ const views = this . getStack ( leavingView . stackId ) ;
81
+ const enteringView = views [ views . length - 2 ] ;
82
+ enteringView . ref . changeDetectorRef . reattach ( ) ;
83
+ this . transition (
84
+ enteringView , // entering view
85
+ leavingView , // leaving view
86
+ 'back' ,
87
+ true ,
88
+ true
89
+ ) ;
90
+ }
82
91
}
83
92
84
93
endBackTransition ( shouldComplete : boolean ) {
@@ -125,6 +134,7 @@ export class StackController {
125
134
const element = view . element ;
126
135
element . setAttribute ( 'aria-hidden' , 'true' ) ;
127
136
element . classList . add ( 'ion-page-hidden' ) ;
137
+ view . ref . changeDetectorRef . detach ( ) ;
128
138
}
129
139
} ) ;
130
140
this . viewsSnapshot = views . slice ( ) ;
@@ -145,11 +155,6 @@ export class StackController {
145
155
this . skipTransition = false ;
146
156
return ;
147
157
}
148
- // TODO
149
- // if (enteringView) {
150
- // enteringView.ref.changeDetectorRef.reattach();
151
- // enteringView.ref.changeDetectorRef.markForCheck();
152
- // }
153
158
const enteringEl = enteringView ? enteringView . element : undefined ;
154
159
const leavingEl = leavingView ? leavingView . element : undefined ;
155
160
const containerEl = this . containerEl ;
0 commit comments