0

Let's say I have a method generateHTML(someAttributes: string) : string.
Calling it with style="color:#fff" would return:

<div style="color:#fff">Test</div>

It works because I'm calling bypassSecurityTrustHtml() on the resulting string.

Now the problem I have is this one: the method now returns something like

<div>
    <p>Some text</p>
    <some-selector [stuff]="test"></some-selector>
    <p>Other text</p>
</div>

some-selector is not interpreted by Angular.

I've been trying to use a ViewRef but it doesn't working in my case because I need to generate a bunch of stuff in one go and the ordering is important (ViewRef adds the component at the end).

Hopefully I'm missing something.
Thank you all for reading!

Kadelka
  • 46
  • 7
  • https://stackoverflow.com/questions/38888008/how-can-i-use-create-dynamic-template-to-compile-dynamic-component-with-angular – Günter Zöchbauer Nov 06 '17 at 04:26
  • check this article [Here is what you need to know about dynamic components in Angular](https://blog.angularindepth.com/here-is-what-you-need-to-know-about-dynamic-components-in-angular-ac1e96167f9e#2b99) – Max Koretskyi Nov 06 '17 at 08:08

0 Answers0