【发布时间】:2015-06-09 04:05:44
【问题描述】:
http://plnkr.co/edit/UfQJU661pQR0DMY3c61t?p=preview
我从 AngularJs 网站获得了上面的代码,唯一的事情是我添加了一个按钮来删除我们有控制器的 Div,但在删除后没有调用任何销毁方法,因为我在指令和控制器中放置了警报。
element.on('$destroy', function() {
alert('destroy directive interval');
$interval.cancel(stopTime);
});
和
$scope.$on('$destroy', function() {
alert('destroy controller interval');
// Make sure that the interval is destroyed too
$scope.stopFight();
});
请提出建议。
谢谢
【问题讨论】: