pavel06081991
pavel06081991

Reputation: 627

removing scope does not work

Unfortunately I did not find the answer by myself in documentation or in google, so maybe you can help me to find out one thing. Just imagine that we have directive "myDirective". It is located on some div element. When I remove this div using remove method from jQuery, then an "$destory" event is triggered on this DOM node. But scope of "myDirective" still exists. I can listen to "$destroy" even on div element and manually call scope.$destroy(), but why angular does not do this?

Upvotes: 0

Views: 62

Answers (1)

chalasr
chalasr

Reputation: 13167

Use the integrated jqLite instead of jQuery. Example :

angular.element(yourElement).remove();

Documentation for angular.element

After, if you have any problem, reset the scope variable related to your directive (if exists) like :

$scope.yourElement = {};

Upvotes: 0

Related Questions