dataSting Comes from database is like:
"<button id =\"play\" class=\"btn btn-simple\" (click)=\"testVideo('math', 'ytv')\"><span class=\"fa fa-play\"></span></button>"
Click function is not working when i clicked on button nothing is happened.
dataSting Comes from database is like:
"<button id =\"play\" class=\"btn btn-simple\" (click)=\"testVideo('math', 'ytv')\"><span class=\"fa fa-play\"></span></button>"
Click function is not working when i clicked on button nothing is happened.
That is not possible, without compiling the newly added code, for the reason that when you are replacing the content with the one returned from the database, it is only treated as plain HTML (it is not compiled and parsed).
When the (click)="testVideo(...)" is part of the HTML that is associated with a component, Angular first parses the HTML, and binds any handlers to the respective functions (which ultimately ends up as native javascript).
In the case when the HTML is added dynamically, during compile time Angular cannot identify the element and the associated click handler (because it is not yet present), without specifically tell angular to do so, hence why it does not work. Ultimately, when the button html is added, the (click) syntax is treated as plain html attribute.
Here's a plunker which demonstrates the above.
This solution https://stackoverflow.com/a/46578036/6666508 might be helpful if you absolutely need to retrieve syntax like the one you've presented from the database.