javascript - Angular 2/4 loading component dynamically in newly added container -
i have angular-module. on "item"-click container added module, happens via jquery ("external" script) , not via angular. want dynamically render component within container.
if have following, can viewcontainerref
of "dynamicjquerycontent":
<button id="clickme">spawn box</button> <div id="dynamicjquerycontent" #dynamicjquerycontent></div>
this works:
@viewchild('dynamicjquerycontent', {read: viewcontainerref}) dynamicjquerycontent: viewcontainerref;
if add new conatiner "dynamicjquerycontent" via jquery:
$("#dynamicjquerycontent").append("<div id='dynamiccomponentcontent' #dynamiccomponentcontent></div>");
this won't work:
@viewchild('dynamiccomponentcontent', {read: viewcontainerref}) dynamiccomponentcontent: viewcontainerref;
i can't viewcontainerref
. i'm not able add dynamic component.
info: i'm able call methods "external" script, e.
here plunker above code... not working.
the solution can either accomplished angular 2 or 4, i'm fine both.
thanks in advance!
best regards julian
Comments
Post a Comment