From 696148f199002adbdfcf864894acf96894e06ed6 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Wed, 10 Aug 2016 20:55:28 -0500 Subject: [PATCH] feat(uiView): Support Components loaded via AppModule --- package.json | 10 +++++----- src/ng2/directives/uiView.ts | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index bea391710..45dea603c 100644 --- a/package.json +++ b/package.json @@ -54,11 +54,11 @@ }, "license": "MIT", "devDependencies": { - "@angular/common": "=2.0.0-rc.3", - "@angular/compiler": "=2.0.0-rc.3", - "@angular/core": "=2.0.0-rc.3", - "@angular/platform-browser": "=2.0.0-rc.3", - "@angular/platform-browser-dynamic": "=2.0.0-rc.3", + "@angular/common": "=2.0.0-rc.5", + "@angular/compiler": "=2.0.0-rc.5", + "@angular/core": "=2.0.0-rc.5", + "@angular/platform-browser": "=2.0.0-rc.5", + "@angular/platform-browser-dynamic": "=2.0.0-rc.5", "babel-core": "^5.8.14", "clone": "^1.0.2", "conventional-changelog": "^1.1.0", diff --git a/src/ng2/directives/uiView.ts b/src/ng2/directives/uiView.ts index 5fcc215c4..a853c494e 100755 --- a/src/ng2/directives/uiView.ts +++ b/src/ng2/directives/uiView.ts @@ -1,6 +1,6 @@ /** @module ng2_directives */ /** */ import { - Component, ComponentResolver, ComponentFactory, + Component, ComponentFactoryResolver, ComponentFactory, ViewContainerRef, ReflectiveInjector, InputMetadata, ComponentMetadata, ViewChild } from '@angular/core'; import {Input} from "@angular/core"; @@ -52,7 +52,7 @@ const ng2ComponentInputs = (ng2CompClass: Type) => { .filter(x => x instanceof ComponentMetadata && !!x.inputs) // Get the .inputs string array .map(x => x.inputs) - .reduce(flattenR) + .reduce(flattenR, []) .map(input => ({ token: input, prop: input })); return _props.concat(inputs) as InputMapping[]; @@ -139,7 +139,7 @@ export class UIView { constructor( public router: UIRouter, @Inject(UIView.PARENT_INJECT) public parent: ParentUIViewInject, - public compResolver: ComponentResolver, + public compFactoryResolver: ComponentFactoryResolver, public viewContainerRef: ViewContainerRef ) { } @@ -193,7 +193,7 @@ export class UIView { rawProviders.push({ provide: UIView.PARENT_INJECT, useValue: { context: config.viewDecl.$context, fqn: uiViewData.fqn } }); // Get the component class from the view declaration. TODO: allow promises? - let componentType = viewDecl.component; + let componentType = viewDecl.component; let createComponent = (factory: ComponentFactory) => { let parentInjector = this.viewContainerRef.injector; @@ -218,7 +218,8 @@ export class UIView { ref.changeDetectorRef.detectChanges(); }; - this.compResolver.resolveComponent(componentType).then(createComponent); + let factory = this.compFactoryResolver.resolveComponentFactory(componentType); + createComponent(factory); } }