Angular Directive - replaceWith, ng-repeat and destroy

148 views Asked by At

I have an array that is used for an ng-repeat. When this is updated, the directive is not currently not removed / destroyed from the DOM.

The link function in the directive does a replaceWith replacing the element with a custom compiled element. Append() worked fine with destroy but it messed up the layout. So I would like to keep the replaceWith if possible.

In the directive I have the following:

element.replaceWith( customElement );

The element is passed via the link function and the customElement is a newly compiled element using the same scope passed via link.

The on destroy event is triggered correctly. However, I have no way of removing the customElement from the DOM. I have tried empty(). remove() and nothing works.

Anyone have any ideas? I can give more info if require.

0

There are 0 answers