I am trying to insert an anchor tag in a string variable. The string will be shown on screen as a link, but it seems to ignore the anchor tag, and only including the value inside the tag. example something turns to just 'something'
private generateAnchors(content: string) {
let contentToReturn = content;
if (content.indexOf('@') < 0) return contentToReturn;
else if (content.indexOf('@') > -1) {
let tag = content.substring(content.indexOf('@'), content.indexOf(' ', content.indexOf('@')));
let address = tag.substring(1, tag.length);
let anchor = '<a href="/home/user/"'+address+'>'+tag+'</a>';
console.log('found substr: '+tag, ' '+address+' '+anchor);
contentToReturn.replace(tag, anchor);
console.log('final string: '+contentToReturn);
}
return contentToReturn;
}
How is this done in Angular/TypeScript ?