If somebody could point me in the right direction, it would be hugely appreciated - I’m just not sure what to search for (term, concept, component, etc). And if code snippets, etc., help please let me know.
I’m building in Ionic 3, targeting iOS and Android.
I have a comment list populating from my server via json and would like to embed “links” in those comments that navigate to a separate view with navParams when clicked. For example, there may be hashtags and/or @ mentions in the comment as below:
Hey @homer check out #simpsons for related information.
I’ve got the regex to parse these out and format them, but I can’t figure out how to assign an event handler for a click dynamically.
Here’s the function/method that I’m working on, that inserts HTML into the comment. I’m totally fine with doing it another way.
formatComment(data) {
data = data.replace(/#(\S*)/g,'<a href="" (click)="console.log(\'Click Event Fired\')">#$1</a>');
return this._sanitizer.bypassSecurityTrustHtml(data);
}
Again, thanks so much in advance.