11/** @module ng2_directives */ /** */
22import {
33 Component , ComponentResolver , ComponentFactory ,
4- ViewContainerRef , ReflectiveInjector , InputMetadata , ComponentMetadata
4+ ViewContainerRef , ReflectiveInjector , InputMetadata , ComponentMetadata , ViewChild
55} from '@angular/core' ;
66import { provide } from "@angular/core" ;
77import { Input } from "@angular/core" ;
@@ -103,7 +103,7 @@ const ng2ComponentInputs = (ng2CompClass) => {
103103 */
104104@Component ( {
105105 selector : 'ui-view, [ui-view]' ,
106- template : ''
106+ template : `<template #componentTarget></template>`
107107 // styles: [`
108108 // .done-true {
109109 // text-decoration: line-through;
@@ -122,6 +122,7 @@ const ng2ComponentInputs = (ng2CompClass) => {
122122 // </div>`
123123} )
124124export class UIView {
125+ @ViewChild ( 'componentTarget' , { read : ViewContainerRef } ) componentTarget ;
125126 @Input ( 'name' ) name : string ;
126127 @Input ( 'ui-view' ) set _name ( val ) { this . name = val ; }
127128 componentRef : ComponentRef < any > ;
@@ -192,7 +193,7 @@ export class UIView {
192193 let createComponent = ( factory : ComponentFactory < any > ) => {
193194 let parentInjector = this . viewContainerRef . injector ;
194195 let childInjector = ReflectiveInjector . resolveAndCreate ( rawProviders , parentInjector ) ;
195- let ref = this . componentRef = this . viewContainerRef . createComponent ( factory , undefined , childInjector ) ;
196+ let ref = this . componentRef = this . componentTarget . createComponent ( factory , undefined , childInjector ) ;
196197
197198 // TODO: wire uiCanExit and uiOnParamsChanged callbacks
198199
0 commit comments