admin管理员组文章数量:1406002
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');
});
本文标签: javascriptAngular JS Directive Unloading Event or EquivalentStack Overflow
版权声明:本文标题:javascript - Angular JS Directive Unloading Event or Equivalent - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744962521a2634743.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论