@angular/core#ComponentFactory TypeScript Examples
The following examples show how to use
@angular/core#ComponentFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: panel-factory.service.ts From ngx-colors with MIT License | 6 votes |
createPanel(
attachTo: string | undefined,
overlayClassName: string | undefined
): ComponentRef<PanelComponent> {
if (this.componentRef != undefined) {
this.removePanel();
}
const factory: ComponentFactory<PanelComponent> =
this.resolver.resolveComponentFactory(PanelComponent);
this.componentRef = factory.create(this.injector);
this.applicationRef.attachView(this.componentRef.hostView);
const domElem = (this.componentRef.hostView as EmbeddedViewRef<any>)
.rootNodes[0] as HTMLElement;
this.overlay = document.createElement("div");
this.overlay.id = "ngx-colors-overlay";
this.overlay.classList.add("ngx-colors-overlay");
this.overlay.classList.add(overlayClassName);
Object.keys(OVERLAY_STYLES).forEach((attr: string) => {
this.overlay.style[attr] = OVERLAY_STYLES[attr];
});
if (attachTo) {
document.getElementById(attachTo).appendChild(this.overlay);
} else {
document.body.appendChild(this.overlay);
}
this.overlay.appendChild(domElem);
return this.componentRef;
}
Example #2
Source File: panel-factory.service.ts From ngx-colors with MIT License | 5 votes |
_factory: ComponentFactory<PanelComponent>;
Example #3
Source File: aem-component.directive.ts From aem-angular-editable-components with Apache License 2.0 | 5 votes |
private renderWithFactory(factory: ComponentFactory<any>) {
this.viewContainer.clear();
this._component = this.viewContainer.createComponent(factory);
this.updateComponentData();
}
Example #4
Source File: ui.service.ts From sba-angular with MIT License | 5 votes |
factories = new Map<Type<any>, ComponentFactory<any>>();
Example #5
Source File: load-component.service.ts From sba-angular with MIT License | 5 votes |
// A cache of resolved component factories
private factories = new Map<Type<any>, ComponentFactory<any>>();