I am using a filter to convert any URL or email id from a piece of content. but its getting rendered as a string not as a clickable HTML element.
Filter JS
angular.module('myApp.filters', []).filter('parseUrl', function() {
var urls = /(\b(https?|ftp):\/\/[A-Z0-9+&@#\/%?=~_|!:,.;-]*[-A-Z0-9+&@#\/%=~_|])/gim
var emails = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim
return function(text) {
if (text.match(urls)) {
text = text.replace(urls, "<a href=\"$1\" target=\"_blank\">$1</a>")
}
if (text.match(emails)) {
text = text.replace(emails, "<a href=\"mailto:$1\">$1</a>")
}
return text
}
});
this above code output me with a plane text and not clickable HTML elements.
testthanmatchwhen you just want to check if a pattern exists in a string