I'm looking to load components from an api I wrote in spring boot which returns HTML.
I want to inject the returned HTML to component, build it and show it to user.
The goal is to make something of a dynamic blog which I can edit and create posts in admin panel (CMS), there for lets say I have two components. First one is to list all of the posts and pages from an api which returns a paged json. Second, the actual post or page. The PROBLEM is that if I want to add a dependency to the HTML from back-end, like apexcharts ( <apexcharts>...</apexcharts>
) or any other packages for that matter, how can we achieve some thing like this?
I have tried dynamic loading of components in angular but did not get the result as some of my tags where not being applied since I used [innerhtml]
CodePudding user response:
You can use Angular's web components package Angular Elements to do this. You create your components as normal, and register them as a custom element. When the tags appear in HTML e.g. via a string passed to innerHTML
, they get rendered as components
Good article on the process by Net Basal here