@@ -17,20 +17,28 @@ import {ViewController} from './view-controller';
17
17
} )
18
18
export class NavRouter extends RouterOutlet {
19
19
private _lastUrl : string ;
20
+ private _nav : Nav ;
21
+ private _parent : Router ;
20
22
21
23
constructor (
22
24
elementRef : ElementRef ,
23
25
loader : DynamicComponentLoader ,
24
- private parentRouter : Router ,
26
+ parentRouter : Router ,
25
27
@Attribute ( 'name' ) nameAttr : string ,
26
- private _nav : Nav
28
+ nav : Nav
27
29
) {
30
+ if ( nav . parent ) {
31
+ parentRouter = parentRouter . childRouter ( nav ) ;
32
+ }
28
33
super ( elementRef , loader , parentRouter , nameAttr ) ;
29
34
35
+ this . _nav = nav ;
36
+ this . _parent = parentRouter ;
37
+
30
38
// register this router with Ionic's NavController
31
39
// Ionic's NavController will call this NavRouter's "stateChange"
32
40
// method when the NavController has...changed its state
33
- _nav . registerRouter ( this ) ;
41
+ nav . registerRouter ( this ) ;
34
42
}
35
43
36
44
stateChange ( direction : string , viewCtrl : ViewController ) {
@@ -57,7 +65,7 @@ export class NavRouter extends RouterOutlet {
57
65
58
66
this . _lastUrl = url ;
59
67
60
- this [ '_parentRouter' ] . navigateByInstruction ( instruction ) ;
68
+ this . _parent . navigateByInstruction ( instruction ) ;
61
69
62
70
console . debug ( 'NavRouter, stateChange, name:' , viewCtrl . name , 'id:' , viewCtrl . id , 'url:' , url ) ;
63
71
}
@@ -68,7 +76,7 @@ export class NavRouter extends RouterOutlet {
68
76
var previousInstruction = this [ '_currentInstruction' ] ;
69
77
this [ '_currentInstruction' ] = nextInstruction ;
70
78
var componentType = nextInstruction . componentType ;
71
- var childRouter = this [ '_parentRouter' ] . childRouter ( componentType ) ;
79
+ var childRouter = this . _parent . childRouter ( componentType ) ;
72
80
73
81
// prevent double navigations to the same view
74
82
let instruction = new ResolvedInstruction ( nextInstruction , null , null ) ;
@@ -92,7 +100,7 @@ export class NavRouter extends RouterOutlet {
92
100
93
101
getPathRecognizerByComponent ( componentType ) {
94
102
// given a componentType, figure out the best PathRecognizer to use
95
- let rules = this . parentRouter . registry [ '_rules' ] ;
103
+ let rules = this . _parent . registry [ '_rules' ] ;
96
104
97
105
let pathRecognizer = null ;
98
106
rules . forEach ( ( rule ) => {
0 commit comments