0

I started to learn Angular recently and I just started to code a project which contains some articles.

Articles are passed from backend completely. (a thing like it)

<p onclick="function" name="itsName" data-info="data">text</p> 

its tags and all attributes are saved in DB exactly like the mentioned example.

Now I am looking to show this data through angular.

[innerHTML] is the common way everyone uses. but it does not render tag's attributes. so my code is not working!

this.content="<div><h2 class='textAlignCenter' (click)='hello()' name='thisis' >"+id+"</h2><div>";

But it shows a thing like it after render :

<div><h2 class='textAlignCenter'>"+id+"</h2><div>

but I am looking to get a result like it.

<div><h2 class='textAlignCenter' (click)='hello()' name='thisis' >changed content - >333</h2><div>
seenukarthi
  • 8,241
  • 10
  • 47
  • 68
  • Go through https://blog.angularindepth.com/here-is-what-you-need-to-know-about-dynamic-components-in-angular-ac1e96167f9e to achieve this – Jay Shukla Oct 31 '19 at 12:13
  • Welcome to StackOverflow! Please make sure to add a minimal verifiable code snippet for others to take a look and understand your problem. For more details on how to create [mcve] – nircraft Oct 31 '19 at 13:05

0 Answers0