mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 10:41:13 +08:00
refactor(angular): remove reflective injector and use static injector instead
This commit is contained in:
@ -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);
|
||||||
|
Reference in New Issue
Block a user