File tree Expand file tree Collapse file tree 2 files changed +48
-8
lines changed Expand file tree Collapse file tree 2 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -106,11 +106,8 @@ import {ViewController} from './view-controller';
106
106
template : '<div #contents></div>'
107
107
} )
108
108
export class Nav extends NavController {
109
-
110
- /**
111
- * @private
112
- */
113
- @Input ( ) root : Type ;
109
+ private _root : Type ;
110
+ private _hasInit : boolean = false ;
114
111
115
112
constructor (
116
113
@Optional ( ) hostNavCtrl : NavController ,
@@ -134,15 +131,32 @@ export class Nav extends NavController {
134
131
}
135
132
}
136
133
134
+ /**
135
+ * @input {Page} The Page component to load as the root page within this nav.
136
+ */
137
+ @Input ( )
138
+ get root ( ) : Type {
139
+ return this . _root ;
140
+ }
141
+ set root ( page : Type ) {
142
+ this . _root = page ;
143
+
144
+ if ( this . _hasInit ) {
145
+ this . setRoot ( page ) ;
146
+ }
147
+ }
148
+
137
149
/**
138
150
* @private
139
151
*/
140
152
ngOnInit ( ) {
141
- if ( this . root ) {
142
- if ( typeof this . root !== 'function' ) {
153
+ this . _hasInit = true ;
154
+
155
+ if ( this . _root ) {
156
+ if ( typeof this . _root !== 'function' ) {
143
157
throw 'The [root] property in <ion-nav> must be given a reference to a component class from within the constructor.' ;
144
158
}
145
- this . push ( this . root ) ;
159
+ this . push ( this . _root ) ;
146
160
}
147
161
}
148
162
Original file line number Diff line number Diff line change
1
+ import { App , Page } from 'ionic-angular' ;
2
+
3
+
4
+ @Page ( {
5
+ template : `
6
+ <ion-content padding text-center>
7
+ Page be loaded!
8
+ </ion-content>
9
+ `
10
+ } )
11
+ class AsyncPage { }
12
+
13
+
14
+ @App ( {
15
+ template : `<ion-nav [root]="root"></ion-nav>`
16
+ } )
17
+ class E2EApp {
18
+ root ;
19
+
20
+ constructor ( ) {
21
+ setTimeout ( ( ) => {
22
+ this . root = AsyncPage ;
23
+ } , 1000 ) ;
24
+
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments