[英]Function not calling added with document.getElementById('someId').appendChild()
我正在從api獲取HTML代碼的一部分,想渲染成如下所示的DOM ...
// getting template from backend. let template1 = "<div class='well'><formio src='example/text.json'></formio>"; //appearing into dom, but not loading form. // second way let template2 = "<formio [src]='getUrl()'></formio></div>"; // calling getUrl from component.ts file. // attaching template into DOM using appendChild() method.. const fragment = document.createRange().createContextualFragment(template); document.getElementById('landingTemplate').appendChild(fragment); getUrl() { return 'example/text.json'; } // getUrl() not calling from HTML.
<div id="landingTemplate"></div>
因此無法渲染formio。 任何人都有主意請幫助我。
當字符串中包含HTML標記時,請使用innerHTML
document.getElementById('landingTemplate').innerHTML = template;
更新
如果確實添加了標記,但您的formio
組件不起作用? ...然后這是您可能正在尋找的幾個鏈接:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.