refactor(angular): change how angular mounts a component, use the angular selector if possible

This commit is contained in:
Dan Bucholtz
2018-01-03 10:32:24 -06:00
parent a63b78b463
commit b54ff41501
4 changed files with 6 additions and 6 deletions

View File

@ -22,8 +22,7 @@ export class IonNavDelegate implements FrameworkDelegate {
attachViewToDom(elementOrContainerToMountTo: HTMLIonNavElement, elementOrComponentToMount: Type<any>, _propsOrDataObj?: any, classesToAdd?: string[]): Promise<AngularMountingData> {
const hostElement = document.createElement('div');
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, hostElement, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd);
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd);
}
removeViewFromDom(_parentElement: HTMLElement, childElement: HTMLElement) {

View File

@ -54,6 +54,9 @@ export function attachViewToDom(crf: ComponentFactoryResolver, parentElement: HT
const componentProviders = ReflectiveInjector.resolve(getProviders(parentElement, data));
const componentFactory = crf.resolveComponentFactory(componentToMount);
if (!hostElement) {
hostElement = document.createElement(componentFactory.selector);
}
const childInjector = ReflectiveInjector.fromResolvedProviders(componentProviders, injector);
const componentRef = componentFactory.create(childInjector, [], hostElement);
for (const clazz of classesToAdd) {

View File

@ -31,8 +31,7 @@ export class ModalController implements FrameworkDelegate {
attachViewToDom(elementOrContainerToMountTo: HTMLElement, elementOrComponentToMount: Type<any>, _propsOrDataObj?: any, classesToAdd?: string[]): Promise<AngularMountingData> {
const hostElement = document.createElement('div');
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, hostElement, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd);
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd);
}
removeViewFromDom(_parentElement: HTMLElement, childElement: HTMLElement) {

View File

@ -31,8 +31,7 @@ export class PopoverController implements FrameworkDelegate {
attachViewToDom(elementOrContainerToMountTo: HTMLElement, elementOrComponentToMount: Type<any>, _propsOrDataObj?: any, classesToAdd?: string[]): Promise<AngularMountingData> {
const hostElement = document.createElement('div');
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, hostElement, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd);
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd);
}
removeViewFromDom(_parentElement: HTMLElement, childElement: HTMLElement) {