I have some text on the scope with tags like this [cid:ce743cbf-8c44-4c84-aa72-6d2c9eb4b81a]
This is generated from an email with some inline content.
I need to go through the text and replace the tags with actual links to those resources. Like this:
<a target="_self" href="/api/attachment/ce743cbf-8c44-4c84-aa72-6d2c9eb4b81a">Name</a>
I am OK now with the replacement part but having trouble creating the actual element with angular.element
.
It all works with pure javascript in this snippet from replacement function:
var link = document.createElement("a");
link.innerText = name;
link.setAttribute("href", url);
link.setAttribute("target", "_self");
return link.outerHTML;
outerHTML refuses to work in Firefox for some reason. How can I do it with angular.element
?
Thanks
UPDATE
At the moment, I can solve the problem with simple string concatenation loke so:
return "<a target=\"_self\" href=" + url + ">" + name + "</a>";
That's the only thing that works with both Firefox and Chrome. But this option just does not feel like the right solution.
UPDATE
OK. I got it working with the help of Robs answer.
var link = angular.element("<a/>", {target: "_self", href: url, text: name});
return angular.element(link).wrap('<div>').parent().html();
This works perfectly with both browsers.