Skip to content

Commit 88c4963

Browse files
docs(jqLite): document "$destroy" event
1 parent 67a81ef commit 88c4963

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/jqLite.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
* Note: All element references in Angular are always wrapped with jQuery or jqLite; they are never
2727
* raw DOM references.
2828
*
29-
* ## Angular's jQuery lite provides the following methods:
29+
* ## Angular's jqLite
30+
* Angular's lite version of jQuery provides only the following jQuery methods:
3031
*
3132
* - [addClass()](http://api.jquery.com/addClass/)
3233
* - [after()](http://api.jquery.com/after/)
@@ -59,8 +60,14 @@
5960
* - [val()](http://api.jquery.com/val/)
6061
* - [wrap()](http://api.jquery.com/wrap/)
6162
*
62-
* ## In addtion to the above, Angular provides additional methods to both jQuery and jQuery lite:
63+
* ## jQuery/jqLite Extras
64+
* Angular also provides the following additional methods and events to both jQuery and jqLite:
6365
*
66+
* ### Events
67+
* - `$destroy` - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event
68+
* on all DOM nodes being removed. This can be used to clean up and 3rd party bindings to the DOM
69+
* element before it is removed.
70+
* ### Methods
6471
* - `controller(name)` - retrieves the controller of the current element or its parent. By default
6572
* retrieves controller associated with the `ngController` directive. If `name` is provided as
6673
* camelCase directive name, then the controller for this directive will be retrieved (e.g.

src/ng/rootScope.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ function $RootScopeProvider(){
446446
*
447447
* @description
448448
* Broadcasted when a scope and its children are being destroyed.
449+
*
450+
* Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to
451+
* clean up DOM bindings before an element is removed from the DOM.
449452
*/
450453

451454
/**
@@ -467,6 +470,9 @@ function $RootScopeProvider(){
467470
* Just before a scope is destroyed a `$destroy` event is broadcasted on this scope.
468471
* Application code can register a `$destroy` event handler that will give it chance to
469472
* perform any necessary cleanup.
473+
*
474+
* Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to
475+
* clean up DOM bindings before an element is removed from the DOM.
470476
*/
471477
$destroy: function() {
472478
// we can't destroy the root scope or a scope that has been already destroyed

0 commit comments

Comments
 (0)