4
說我有指令:當一個元素從指令中被移除時,AngularJs是否會自動銷燬範圍?
angular.module('myApp').directive('myDirective', function ($compile) {
return {
link: function ($scope, $element, $attrs) {
var $randomElem = $('<div>');
$element.append($compile($randomElem)($scope));
$randomElem.remove();
}
}
});
將範圍自動銷燬?如果不是,我該如何摧毀它?