Dynamic add component using gridstack and angular2? Jquery $.parseHTML does not work

后端 未结 2 1360
梦谈多话
梦谈多话 2021-01-04 02:59

I have the following jsfiddle

I want to be able to stick my custom component into a specific grid (e.g. \"\")

Right now without Angular2, I just use:

2条回答
  •  甜味超标
    2021-01-04 03:35

    You need to use Angular 2’s ViewContainerRef class, which provides a handy createComponent method. The ViewContainerRef can be informally thought of as a location in the DOM where new components can be inserted.

    this.cmpRef = this.vcRef.createComponent(factory, 0, injector, []);
    

    Here's a working plunker example.

    Or you can use the generic HTML outlete from this post

提交回复
热议问题