$document.cookie test
by provegard
HTML
<script src="https:////code.angularjs.org/1.2.23/angular.js"></script>
<div ng-controller="Ctrl">
<div foobar class="foobar">THE DIV</div>
<button ng-click="rem()">Remove</button>
</div>
JavaScript
angular
.module("myApp", [])
.controller("Ctrl", ["$document", "$scope", function($document, $scope) {
$scope.rem = function () {
angular.element(".foobar").remove();
};
}])
.directive("foobar", function () {
return {
scope: {},
link: function (scope, element, attrs) {
element.on("$destroy", function () {
alert("element destroy");
});
scope.$on("$destroy", function () {
alert("scope destroy");
});
}
};
});