Skip to content

Commit

Permalink
fix(ng2.UIView): Make routed to component appear *inside* UIView, not…
Browse files Browse the repository at this point in the history
… next to it.
  • Loading branch information
christopherthielen committed Jun 30, 2016
1 parent 822fc10 commit 558fc80
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ng2/directives/uiView.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @module ng2_directives */ /** */
import {
Component, ComponentResolver, ComponentFactory,
ViewContainerRef, ReflectiveInjector, InputMetadata, ComponentMetadata
ViewContainerRef, ReflectiveInjector, InputMetadata, ComponentMetadata, ViewChild
} from '@angular/core';
import {provide} from "@angular/core";
import {Input} from "@angular/core";
Expand Down Expand Up @@ -103,7 +103,7 @@ const ng2ComponentInputs = (ng2CompClass) => {
*/
@Component({
selector: 'ui-view, [ui-view]',
template: ''
template: `<template #componentTarget></template>`
// styles: [`
// .done-true {
// text-decoration: line-through;
Expand All @@ -122,6 +122,7 @@ const ng2ComponentInputs = (ng2CompClass) => {
// </div>`
})
export class UIView {
@ViewChild('componentTarget', {read: ViewContainerRef}) componentTarget;
@Input('name') name: string;
@Input('ui-view') set _name(val) { this.name = val; }
componentRef: ComponentRef<any>;
Expand Down Expand Up @@ -192,7 +193,7 @@ export class UIView {
let createComponent = (factory: ComponentFactory<any>) => {
let parentInjector = this.viewContainerRef.injector;
let childInjector = ReflectiveInjector.resolveAndCreate(rawProviders, parentInjector);
let ref = this.componentRef = this.viewContainerRef.createComponent(factory, undefined, childInjector);
let ref = this.componentRef = this.componentTarget.createComponent(factory, undefined, childInjector);

// TODO: wire uiCanExit and uiOnParamsChanged callbacks

Expand Down

0 comments on commit 558fc80

Please sign in to comment.