如何使用drag和drog angular2添加动态组件

时间:2016-07-07 08:36:26

标签: typescript angular drag-and-drop

如何通过拖放动态添加组件

这是我尝试添加我的组件但不起作用的地方

    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

0 个答案:

没有答案