@ionic/angular
Advanced tools
Comparing version 0.0.2-16 to 0.0.2-17
@@ -13,3 +13,3 @@ import { ComponentFactoryResolver, Directive, ElementRef, Injector, } from '@angular/core'; | ||
// wrap whatever the user provides in an ion-page | ||
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd, true); | ||
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd); | ||
} | ||
@@ -16,0 +16,0 @@ removeViewFromDom(parentElement, childElement) { |
@@ -8,7 +8,6 @@ import { ApplicationRef, ComponentFactoryResolver, Injector, NgZone, Type } from '@angular/core'; | ||
constructor(defaultCfr: ComponentFactoryResolver, zone: NgZone, appRef: ApplicationRef); | ||
attachViewToDom(parentElement: HTMLElement, hostElement: HTMLElement, componentToMount: Type<any>, componentResolveFactory: ComponentFactoryResolver, injector: Injector, data: any, classesToAdd: string[], wrapUserComponentInIonPage: boolean): Promise<AngularMountingData>; | ||
attachViewToDom(parentElement: HTMLElement, hostElement: HTMLElement, componentToMount: Type<any>, componentResolveFactory: ComponentFactoryResolver, injector: Injector, data: any, classesToAdd: string[]): Promise<AngularMountingData>; | ||
removeViewFromDom(parentElement: HTMLElement, childElement: HTMLElement): Promise<any>; | ||
} | ||
export declare function removeViewFromDom(parentElement: HTMLElement, childElement: HTMLElement): void; | ||
export declare function attachViewToDom(crf: ComponentFactoryResolver, parentElement: HTMLElement, hostElement: HTMLElement, componentToMount: Type<any>, injector: Injector, appRef: ApplicationRef, data: any, classesToAdd: string[], wrapUserComponentInIonPage: boolean): AngularMountingData; | ||
export declare function getIonPageElement(hostElement: HTMLElement): HTMLIonPageElement; | ||
export declare function removeViewFromDom(_parentElement: HTMLElement, childElement: HTMLElement): void; | ||
export declare function attachViewToDom(crf: ComponentFactoryResolver, parentElement: HTMLElement, hostElement: HTMLElement, componentToMount: Type<any>, injector: Injector, appRef: ApplicationRef, data: any, classesToAdd: string[]): AngularMountingData; |
@@ -10,7 +10,7 @@ import { ApplicationRef, ComponentFactoryResolver, Injectable, NgZone, ReflectiveInjector } from '@angular/core'; | ||
} | ||
attachViewToDom(parentElement, hostElement, componentToMount, componentResolveFactory, injector, data, classesToAdd, wrapUserComponentInIonPage) { | ||
attachViewToDom(parentElement, hostElement, componentToMount, componentResolveFactory, injector, data, classesToAdd) { | ||
return new Promise((resolve) => { | ||
this.zone.run(() => { | ||
const crf = componentResolveFactory ? componentResolveFactory : this.defaultCfr; | ||
const mountingData = attachViewToDom(crf, parentElement, hostElement, componentToMount, injector, this.appRef, data, classesToAdd, wrapUserComponentInIonPage); | ||
const mountingData = attachViewToDom(crf, parentElement, hostElement, componentToMount, injector, this.appRef, data, classesToAdd); | ||
resolve(mountingData); | ||
@@ -38,13 +38,9 @@ }); | ||
]; | ||
export function removeViewFromDom(parentElement, childElement) { | ||
export function removeViewFromDom(_parentElement, childElement) { | ||
const mountingData = elementToComponentRefMap.get(childElement); | ||
if (mountingData) { | ||
const componentParent = mountingData.element.parentNode; | ||
mountingData.componentRef.destroy(); | ||
if (mountingData.wrapUserComponentInIonPage && parentElement.contains(componentParent)) { | ||
parentElement.removeChild(componentParent); | ||
} | ||
} | ||
} | ||
export function attachViewToDom(crf, parentElement, hostElement, componentToMount, injector, appRef, data, classesToAdd, wrapUserComponentInIonPage) { | ||
export function attachViewToDom(crf, parentElement, hostElement, componentToMount, injector, appRef, data, classesToAdd) { | ||
const componentProviders = ReflectiveInjector.resolve(getProviders(parentElement, data)); | ||
@@ -60,4 +56,3 @@ const componentFactory = crf.resolveComponentFactory(componentToMount); | ||
} | ||
const elementToAppend = wrapUserComponentInIonPage ? getIonPageElement(hostElement) : hostElement; | ||
parentElement.appendChild(elementToAppend); | ||
parentElement.appendChild(hostElement); | ||
appRef.attachView(componentRef.hostView); | ||
@@ -71,3 +66,2 @@ const mountingData = { | ||
element: hostElement, | ||
wrapUserComponentInIonPage | ||
}; | ||
@@ -77,7 +71,2 @@ elementToComponentRefMap.set(hostElement, mountingData); | ||
} | ||
export function getIonPageElement(hostElement) { | ||
const page = document.createElement('ion-page'); | ||
page.appendChild(hostElement); | ||
return page; | ||
} | ||
//# sourceMappingURL=angular-component-mounter.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":4,"metadata":{"AngularComponentMounter":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":15,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ComponentFactoryResolver","line":18,"character":34},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":18,"character":74},{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef","line":18,"character":98}]}],"attachViewToDom":[{"__symbolic":"method"}],"removeViewFromDom":[{"__symbolic":"method"}]}},"removeViewFromDom":{"__symbolic":"function"},"attachViewToDom":{"__symbolic":"function"},"getIonPageElement":{"__symbolic":"function"}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"AngularComponentMounter":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":15,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ComponentFactoryResolver","line":18,"character":34},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":18,"character":74},{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef","line":18,"character":98}]}],"attachViewToDom":[{"__symbolic":"method"}],"removeViewFromDom":[{"__symbolic":"method"}]}},"removeViewFromDom":{"__symbolic":"function"},"attachViewToDom":{"__symbolic":"function"}}}] |
@@ -22,3 +22,3 @@ import { ComponentFactoryResolver, Injectable, Injector, } from '@angular/core'; | ||
attachViewToDom(elementOrContainerToMountTo, elementOrComponentToMount, _propsOrDataObj, classesToAdd) { | ||
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd, true); | ||
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd); | ||
} | ||
@@ -25,0 +25,0 @@ removeViewFromDom(parentElement, childElement) { |
@@ -16,3 +16,3 @@ import { ComponentFactoryResolver, Injectable, Injector, } from '@angular/core'; | ||
attachViewToDom(elementOrContainerToMountTo, elementOrComponentToMount, _propsOrDataObj, classesToAdd) { | ||
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd, false); | ||
return this.angularComponentMounter.attachViewToDom(elementOrContainerToMountTo, null, elementOrComponentToMount, this.componentResolveFactory, this.injector, _propsOrDataObj, classesToAdd); | ||
} | ||
@@ -19,0 +19,0 @@ removeViewFromDom(parentElement, childElement) { |
@@ -9,3 +9,2 @@ import { ComponentFactory, ComponentRef, Injector } from '@angular/core'; | ||
angularHostElement?: HTMLElement; | ||
wrapUserComponentInIonPage?: boolean; | ||
} |
{ | ||
"name": "@ionic/angular", | ||
"version": "0.0.2-16", | ||
"version": "0.0.2-17", | ||
"description": "Angular specific wrappers for @ionic/core", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
128973
1685