当元素被删除angularJS通知 [英] angularJS notification when element is removed

查看:118
本文介绍了当元素被删除angularJS通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个新的指令,我想知道如何通知从DOM角度时删除元素。结果
我的目标是添加,当元件被除去的jquery动画。

I am creating a new directive and I wondering how to be notified when angular remove the element from the DOM.
My aim is to add a jquery animation when an element is removed.

推荐答案

如果你想制作动画你需要它被删除之前,这样做去除元素。

If you are trying to animate the removal of element you need to do this before it is removed.

我创建了一个小提琴证明了这种

I've created a fiddle demonstrating this.

在你听的 $摧毁事件的第一个节角呼叫正在从DOM中删除元素。

In the first section you listen the $destroy event that angular call to elements that are being removed from DOM.

在第二种情况下我创建了一个指令,淡出和删除元素自动完成的。

In the second case I've created a directive that fadeOut and remove the element automatic.

在第三种情况下的指令只是淡出的元件和除去被传递到控制器。

In the third case the directive just fadeOut the element and the removal is passed to controller.

如果你想淡出被移除,那么你不能使用第一个选项。元素

If you want to fadeOut the element that are removed then you can't use the first option.

第二和第三I个人建议第三,因为它更灵活之间

Between the second and the third I personally suggest the third because it is more flexible.

这篇关于当元素被删除angularJS通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆