1
1
/** @module ng2_directives */ /** */
2
2
import {
3
3
Component , ComponentResolver , ComponentFactory ,
4
- ViewContainerRef , ReflectiveInjector , InputMetadata , ComponentMetadata
4
+ ViewContainerRef , ReflectiveInjector , InputMetadata , ComponentMetadata , ViewChild
5
5
} from '@angular/core' ;
6
6
import { provide } from "@angular/core" ;
7
7
import { Input } from "@angular/core" ;
@@ -103,7 +103,7 @@ const ng2ComponentInputs = (ng2CompClass) => {
103
103
*/
104
104
@Component ( {
105
105
selector : 'ui-view, [ui-view]' ,
106
- template : ''
106
+ template : `<template #componentTarget></template>`
107
107
// styles: [`
108
108
// .done-true {
109
109
// text-decoration: line-through;
@@ -122,6 +122,7 @@ const ng2ComponentInputs = (ng2CompClass) => {
122
122
// </div>`
123
123
} )
124
124
export class UIView {
125
+ @ViewChild ( 'componentTarget' , { read : ViewContainerRef } ) componentTarget ;
125
126
@Input ( 'name' ) name : string ;
126
127
@Input ( 'ui-view' ) set _name ( val ) { this . name = val ; }
127
128
componentRef : ComponentRef < any > ;
@@ -192,7 +193,7 @@ export class UIView {
192
193
let createComponent = ( factory : ComponentFactory < any > ) => {
193
194
let parentInjector = this . viewContainerRef . injector ;
194
195
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 ) ;
196
197
197
198
// TODO: wire uiCanExit and uiOnParamsChanged callbacks
198
199
0 commit comments