Why rest api html data click attribute not working in angular 2 ? is there any way to do like angular 1?

Thanks for reading my question.

we have rest api and which send some html which has click attribute . in angular 1 we use compile so if ng-click added from rest api it works fine Now in angular 2 how to do that type if we use innterHtml then it ignore click attribute

we have html from rest api like

$rHtmlData='<a href="" (click)="confirm_action()">Demo</a><p>any other data</p>';

now we need to bind that same in angular 2.

If any one help me it will be really great help to me.


If you don’t get any better answers, I pretend that innerHTML doesn’t exist, because as you have observed it doesn’t do what people typically expect it to. I use this strategy and enforce a rule in my designs that no HTML passes between backends and mobile apps; only business-domain JSON data.


thank you .
but sorry not getting .
Can you please elaborate little more.