refactor(angular): remove reflective injector and use static injector instead

This commit is contained in:
Dan Bucholtz
2018-02-15 16:25:06 -06:00
parent 297324c19e
commit 4524d59e46

View File

@ -4,7 +4,6 @@ import {
Injectable, Injectable,
Injector, Injector,
NgZone, NgZone,
ReflectiveInjector,
Type Type
} from '@angular/core'; } from '@angular/core';
@ -43,13 +42,13 @@ export class AngularComponentMounter {
attachViewToDomImpl(crf: ComponentFactoryResolver, parentElement: HTMLElement, hostElement: HTMLElement, componentToMount: Type<any>, injector: Injector, appRef: ApplicationRef, data: any, classesToAdd: string[]): AngularMountingData { attachViewToDomImpl(crf: ComponentFactoryResolver, parentElement: HTMLElement, hostElement: HTMLElement, componentToMount: Type<any>, injector: Injector, appRef: ApplicationRef, data: any, classesToAdd: string[]): AngularMountingData {
const componentProviders = ReflectiveInjector.resolve(getProviders(parentElement, data));
const componentFactory = crf.resolveComponentFactory(componentToMount); const componentFactory = crf.resolveComponentFactory(componentToMount);
if (!hostElement) { if (!hostElement) {
hostElement = document.createElement(componentFactory.selector); hostElement = document.createElement(componentFactory.selector);
} }
const childInjector = ReflectiveInjector.fromResolvedProviders(componentProviders, injector); const childInjector = Injector.create(getProviders(parentElement, data), injector);
const componentRef = componentFactory.create(childInjector, [], hostElement); const componentRef = componentFactory.create(childInjector, [], hostElement);
for (const clazz of classesToAdd) { for (const clazz of classesToAdd) {
hostElement.classList.add(clazz); hostElement.classList.add(clazz);