[SOLVED] angularJS notification when element is removed- Angular.js Recipes

  • I am creating a new directive and I wondering how to be notified when angular remove the element from the DOM.
  • In the first section you listen the 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.

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.

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.

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


@angular_recipe: angularJS notification when element is removed #Angular #AngularJS

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.

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.

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

There is currently no discussion for this recipe.

Angular.js Recipes are structured in a Cookbook format featuring recipes that contain problem statements and solutions. A detailed explanation follows each problem statement of the recipe. This is usually contained within the solution; however, an optional discussion section can often contain other useful information helping to demonstrate how the solution works.

Angular.js is a JavaScript-based open-source front-end web application framework mainly maintained by Google and by a community of individuals and corporations to address many of the challenges encountered in developing single-page applications. The JavaScript components complement Apache Cordova, the framework used for developing cross-platform mobile apps. It aims to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) and model–view–viewmodel (MVVM) architectures, along with components commonly used in rich Internet applications.

Lost? Begin by working through Angular’s Getting Started Guide to get yourself up-and-running.

[SOLVED] angularJS notification when element is removed- Angular.js Recipes

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.