I am trying to manipulate the html of a table to replace all text in cells that have links with a <a> link that is clickable using AngularJS.
When the DOM is loaded I have the following code:
...
$("td").each(function (index) {
if($(this).text())
{
$(this).text($ctrl.linkify($(this).text().toString()));
}
});
...
$ctrl.linkify = function(text) {
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(urlRegex, function (url) {
return '<a href="' + url + '">' + url + '</a>';
});
}
However it doesn't render the links as clickable link elements.
An important note is that the table is added dynamically by a third party plugin so I can only manipulate it after it has loaded. Hence why in the title I mentioned after the table has been rendered.
How can I use angular js to linkify the cells? Or use sanitize to render the new html?


You are seeing it as text because ng-model or {{}} shows only text, you need to show them as html and in this case you can use ngBingHtml directive. To use it, you must include into your project angular-sanitize and after it in your table you can use in this way:
Here a working example