Currently, I am attempting to integrate a wysiwyg editor into my Angular application. The objective is to retrieve an array of objects by querying an endpoint, then format the data within each object based on its property name with different HTML tags. Finally, all the formatted data will be combined into a string and displayed in the wysiwyg editor within my app.
For example, given JSON like this:
[
{
"name": "steve",
"age": 33,
"profile": "http://www.profile.com/steve",
"location": "New York"
},{
"name": "john",
"age": 25,
"profile": "http://www.profile.com/john",
"location": "LA"
},
]
The output would be:
"<b>Steve - New York</b>
<br>
<a href='http://www.profile.com/steve'>Url</a>
<br>
<span>33</span>
<br>
<br>
<b>John - LA</b>
<br>
<a href='http://www.profile.com/john'>Url</a>
<br>
<span>25</span>
<br>
<br>"
Although this functionality is not specific to Angular, it would be beneficial to encapsulate this logic within a service for reusability throughout the application.
I am uncertain about how to structure this code. Any suggestions or ideas?
EDIT: To clarify, the reason behind implementing this feature is to accommodate non-technical users who need to edit content in the wysiwyg editor and export it as a PDF file from the application. Both the wysiwyg editor and backend system require the content to be in a single HTML-tagged string format.