I'm working on a directive where I also need to append a child element on update. So far, I have implemented the following solution:
var el = $compile('<a href="http://' + image.url + '">' + image.name + '</a>')(scope);
element.append(el);
While this method works, it has the downside of always appending a new link tag without removing the previous one. How can I remove the existing link tag and add a new one on update? Alternatively, is there a better approach to achieve this?