Skip to content

Commit 52123ae

Browse files
docs(jqLite): document "$destroy" event
1 parent 3e39ac7 commit 52123ae

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/)
@@ -61,8 +62,14 @@
6162
* - [val()](http://api.jquery.com/val/)
6263
* - [wrap()](http://api.jquery.com/wrap/)
6364
*
64-
* ## In addition to the above, Angular provides additional methods to both jQuery and jQuery lite:
65+
* ## jQuery/jqLite Extras
66+
* Angular also provides the following additional methods and events to both jQuery and jqLite:
6567
*
68+
* ### Events
69+
* - `$destroy` - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event
70+
* on all DOM nodes being removed. This can be used to clean up and 3rd party bindings to the DOM
71+
* element before it is removed.
72+
* ### Methods
6673
* - `controller(name)` - retrieves the controller of the current element or its parent. By default
6774
* retrieves controller associated with the `ngController` directive. If `name` is provided as
6875
* 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
@@ -575,6 +575,9 @@ function $RootScopeProvider(){
575575
*
576576
* @description
577577
* Broadcasted when a scope and its children are being destroyed.
578+
*
579+
* Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to
580+
* clean up DOM bindings before an element is removed from the DOM.
578581
*/
579582

580583
/**
@@ -596,6 +599,9 @@ function $RootScopeProvider(){
596599
* Just before a scope is destroyed a `$destroy` event is broadcasted on this scope.
597600
* Application code can register a `$destroy` event handler that will give it chance to
598601
* perform any necessary cleanup.
602+
*
603+
* Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to
604+
* clean up DOM bindings before an element is removed from the DOM.
599605
*/
600606
$destroy: function() {
601607
// we can't destroy the root scope or a scope that has been already destroyed

0 commit comments

Comments
 (0)