@@ -3,7 +3,7 @@ import {isBlank, isPresent} from '@angular/core/src/facade/lang';
3
3
import { StringMapWrapper } from '@angular/core/src/facade/collection' ;
4
4
5
5
import { Attribute , DynamicComponentLoader , ComponentRef , ViewContainerRef ,
6
- ElementRef , ReflectiveInjector , provide , Type , Component } from '@angular/core' ;
6
+ ElementRef , ReflectiveInjector , provide , Type , Component , Inject } from '@angular/core' ;
7
7
8
8
import * as routerHooks from '@angular/router/src/lifecycle/lifecycle_annotations' ;
9
9
import { hasLifecycleHook } from '@angular/router/src/lifecycle/route_lifecycle_reflector' ;
@@ -13,9 +13,12 @@ import {Router, RouterOutlet, RouteData, RouteParams, ComponentInstruction,
13
13
import { LocationStrategy } from '@angular/common' ;
14
14
import { topmost } from "ui/frame" ;
15
15
import { Page , NavigatedData } from "ui/page" ;
16
+ import { DEVICE } from "../platform-providers" ;
17
+ import { Device } from "platform" ;
16
18
import { log } from "./common" ;
17
19
import { NSLocationStrategy } from "./ns-location-strategy" ;
18
20
import { DetachedLoader } from "../common/detached-loader" ;
21
+ import { ViewUtil } from "../view-util" ;
19
22
20
23
let _resolveToTrue = PromiseWrapper . resolve ( true ) ;
21
24
@@ -66,13 +69,17 @@ export class PageRouterOutlet extends RouterOutlet {
66
69
67
70
private componentRef : ComponentRef = null ;
68
71
private currentInstruction : ComponentInstruction = null ;
72
+ private viewUtil : ViewUtil ;
69
73
70
74
constructor ( private containerRef : ViewContainerRef ,
71
75
private loader : DynamicComponentLoader ,
72
76
private parentRouter : Router ,
73
77
@Attribute ( 'name' ) nameAttr : string ,
74
- private location : NSLocationStrategy ) {
78
+ private location : NSLocationStrategy ,
79
+ @Inject ( DEVICE ) device : Device
80
+ ) {
75
81
super ( containerRef , loader , parentRouter , nameAttr ) ;
82
+ this . viewUtil = new ViewUtil ( device ) ;
76
83
}
77
84
78
85
/**
@@ -154,9 +161,7 @@ export class PageRouterOutlet extends RouterOutlet {
154
161
//Component loaded. Find its root native view.
155
162
const componentView = componentRef . location . nativeElement ;
156
163
//Remove it from original native parent.
157
- if ( < any > componentView . parent ) {
158
- ( < any > componentView . parent ) . removeChild ( componentView ) ;
159
- }
164
+ this . viewUtil . removeChild ( componentView . parent , componentView ) ;
160
165
//Add it to the new page
161
166
page . content = componentView ;
162
167
0 commit comments