1

I have a directive where i need also to append child element on update, what i have done is this:

var el = $compile('<a href="http://' + image.url + '">' + image.name + '</a>')( scope );
element.append(el);

This works, but on update it will always append new link tag without removing the previous one, how can i remove the existing and add new one? Or there is a better way of doing this?

1
  • Post your directive code as well so that what you are trying to do is clear. Commented May 19, 2016 at 18:39

1 Answer 1

2

call element.empty() before element.append()

but i would recommend using ng-href directive.

<a ng-href="http://{{image.url}}">{{image.name}}</a>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.