angular - How to bind (click) from dynamic generated html in agular 4? -
i have component generate html , same variable. can display ok on template needs go, (click) function not working on html. best way working?
i have working this, correct way it?
import { component, oninit, viewchild, aftercontentinit, renderer2 } '@angular/core'; ngaftercontentinit() { const global = this.renderer.listen('document', 'click', (event) => { const element = event.target htmlelement; if (element.classlist.contains('navbox-title') || element.classlist.contains('wrap-title')) { const nodeid = event.target.dataset.nodeid; this.gotonode(nodeid); } }); } myfunction () { this.disphtml = '<div data-nodeid="${value.id}" class="navbox-title">'.....; }
Comments
Post a Comment