So, I have these widgets:
<widget ng-repeat="widget in widgets"></widget>
As you can tell, they are created and removed by the ng-repeat
.
So when someone does remove a widget, is there any where in the directive I can catch the event happening OR equivalent?
.directive('widget', function widget() {
var directive = {
restrict: 'E',
pile: pile
};
return directive;
function pile() {
return {
pre: preLink,
post: postLink
};
}
function preLink(scope, element) {
}
function postLink(scope, element) {
}
});
So, I have these widgets:
<widget ng-repeat="widget in widgets"></widget>
As you can tell, they are created and removed by the ng-repeat
.
So when someone does remove a widget, is there any where in the directive I can catch the event happening OR equivalent?
.directive('widget', function widget() {
var directive = {
restrict: 'E',
pile: pile
};
return directive;
function pile() {
return {
pre: preLink,
post: postLink
};
}
function preLink(scope, element) {
}
function postLink(scope, element) {
}
});
Share
Improve this question
asked Jan 19, 2015 at 11:40
Callum LiningtonCallum Linington
14.4k14 gold badges80 silver badges156 bronze badges
1 Answer
Reset to default 9You can listen to the $destroy event which will be fired immediately prior to scope destruction.
The $destroy() is usually used by directives such as ngRepeat for managing the unrolling of the loop.
scope.$on('$destroy', function () {
console.log('captured $destroy event');
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744962521a4603475.html
评论列表(0条)