jqLite is a tiny, API-compatible subset of jQuery that allows Angular to manipulate the DOM in a cross-browser compatible way. jqLite implements only the most commonly needed functionality with the goal of having a very small footprint.
angular.element is a function in module ng which wWraps a raw DOM element or HTML string as a jQuery element.
To use jQuery, simply load it before DOMContentLoaded event fired.
If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular’s built-in subset of jQuery, called "jQuery lite" or "jqLite."
Note: all element references in Angular are always wrapped with jQuery or jqLite; they are never raw DOM references.
jqLite provides only the following jQuery methods:
-
addClass() : http://api.jquery.com/addclass/
-
after(): http://api.jquery.com/after/
-
append(): http://api.jquery.com/append/
-
attr(): http://api.jquery.com/after/
-
bind() : http://api.jquery.com/bind/ - Does not support namespaces, selectors or eventData
-
children(): http://api.jquery.com/children/ - Does not support selectors
-
clone(): http://api.jquery.com/clone/
-
contents(): http://api.jquery.com/contents/
-
css(): http://api.jquery.com/css/
-
data(): http://api.jquery.com/data/
-
empty(): http://api.jquery.com/empty/
-
find(): http://api.jquery.com/find/ - Limited to lookups by tag name
-
hasClass(): http://api.jquery.com/hasClass/
-
html(): http://api.jquery.com/html/
-
next(): http://api.jquery.com/next/ - Does not support selectors
-
on(): http://api.jquery.com/on/ - Does not support namespaces, selectors or eventData
-
off(): http://api.jquery.com/off/ - Does not support namespaces or selectors
-
one(): http://api.jquery.com/one/ - Does not support namespaces or selectors
-
parent(): http://api.jquery.com/parent/ - Does not support selectors
-
prepend(): http://api.jquery.com/prepend/
-
prop(): http://api.jquery.com/prop/
-
ready(): http://api.jquery.com/ready/
-
remove(): http://api.jquery.com/remove/
-
removeAttr(): http://api.jquery.com/removeAttr/
-
removeClass(): http://api.jquery.com/removeClass/
-
removeData(): http://api.jquery.com/removeData/
-
replaceWith(): http://api.jquery.com/replaceWith/
-
text(): http://api.jquery.com/text/
-
toggleClass(): http://api.jquery.com/toggleClass/
-
triggerHandler(): http://api.jquery.com/triggerHandler/ - Passes a dummy event object to handlers.
-
unbind(): http://api.jquery.com/unbind/ - Does not support namespaces
-
val(): http://api.jquery.com/val/
-
wrap(): http://api.jquery.com/wrap/
Angular also provides the following additional methods and events to both jQuery and jqLite:
$destroy - AngularJS intercepts all jqLite/jQuery’s DOM destruction apis and fires this event on all DOM nodes being removed. This can be used to clean up any 3rd party bindings to the DOM element before it is removed.
-
controller(name) - retrieves the controller of the current element or its parent. By default retrieves controller associated with the ngController directive. If name is provided as camelCase directive name, then the controller for this directive will be retrieved (e.g. 'ngModel').
-
injector() - retrieves the injector of the current element or its parent.
-
scope() - retrieves the scope of the current element or its parent.
-
isolateScope() - retrieves an isolate scope if one is attached directly to the current element. This getter should be used only on elements that contain a directive which starts a new isolate scope. Calling scope() on this element always returns the original non-isolate scope.
-
inheritedData() - same as data(), but walks up the DOM until a value is found or the top parent element is reached.