如何通过拖放动态添加组件
这是我尝试添加我的组件但不起作用的地方
onDrop(event:DragEvent) {
console.log("target "+ this.target);
this.elementDrop = this.el.nativeElement;
event.preventDefault();
//////////////
this.resolver.resolveComponent(Div444).then((factory) => {
this.componentRef = this.component_target.createComponent(factory);
});
///////////
this.renderer.setElementStyle(this.el.nativeElement, 'borderStyle', 'bridge');
this.renderer.setElementStyle(this.el.nativeElement, 'borderColor', 'white');
console.log("is dropped !");
}
我收到了错误
EXCEPTION: Error: Uncaught (in promise): TypeError: _this.component_target.createComponent is not a
browser_adapter.ts:78 Error: Uncaught (in promise): TypeError: _this.component_target.createComponent is not a function