Skip to content Skip to sidebar Skip to footer

Event Not Working In Dynamic Html In Angular2

Want to append the dynamic generated html in a DOM, its appending successfully in a DOM but none of the function is working like click etc. ngOnInit() { this.sideBarData +

Solution 1:

Setting html in DOM directly by yourself isn't the right way of doing things in Angular. The right way is to split your code into Components, where each Component should have it's own responsibilaty (S in S.O.L.I.D.).

And for this kind of interactivaty (showing/hiding, styling) you should use: ngIf, ngSwitch, ngClass in your templates.


Post a Comment for "Event Not Working In Dynamic Html In Angular2"