Clickable link within text from backend

Hi there,

I’m getting a text block from my backend, and trying to highlight URLs to open an in-app browser with a click event.

Ie. some text might say: “Here is a link: https://google.com”.

I tried adding a new element dynamically, with a (click) event, and got that to work using https://github.com/apoterenko/ngx-dynamic-template, but it fails with AOT compilation.

Does anyone have ideas in how to trigger a (click) event on a certain piece of text that is received from the backend?

Thanks,
John

I know this is so late for a reply but I stumbled upon this scenario recently and this is what I did.

You can use [innerHtml] to render html contents

For your given example, try:

this.textBlock = "<p>Here is a link <a href='https://google.com'>https://google.com</a></p>";

<p ion-text [innerHtml]="textBlock"></p>