View source Improve this doc

# `angular.element`
API in module `ng`

## Description

Wraps a raw DOM element or HTML string as a jQuery element. `angular.element` can be either an alias for jQuery function, if jQuery is available, or a function that wraps the element or string in Angular's jQuery lite implementation (commonly referred to as jqLite).

Real jQuery always takes precedence over jqLite, provided it was loaded before `DOMContentLoaded` event fired.

jqLite is a tiny, API-compatible subset of jQuery that allows Angular to manipulate the DOM. jqLite implements only the most commonly needed functionality within a very small footprint, so only a subset of the jQuery API - methods, arguments and invocation styles - are supported.

Note: All element references in Angular are always wrapped with jQuery or jqLite; they are never raw DOM references.

#### Angular's jqLite

Angular's lite version of jQuery provides only the following jQuery methods:

- addClass()
- after()
- append()
- attr()
- bind() - Does not support namespaces, selectors or eventData
- children() - Does not support selectors
- clone()
- contents()
- css()
- data()
- eq()
- find() - Limited to lookups by tag name
- hasClass()
- html()
- next() - Does not support selectors
- on() - Does not support namespaces, selectors or eventData
- off() - Does not support namespaces or selectors
- parent() - Does not support selectors
- prepend()
- prop()
- ready()
- remove()
- removeAttr()
- removeClass()
- removeData()
- replaceWith()
- text()
- toggleClass()
- triggerHandler() - Passes a dummy event object to handlers.
- unbind() - Does not support namespaces
- val()
- wrap()

## jQuery/jqLite Extras

Angular also provides the following additional methods and events to both jQuery and jqLite:

##### Events

- `$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 and 3rd party bindings to the DOM element before it is removed.

  ### Methods

- `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.
- `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top parent element is reached.

## Usage

    angular.element(element);

#### Parameters

Param | Type | Details
--- | --- | ---
element | string DOMElement | HTML string or DOMElement to be wrapped into jQuery.

#### Returns

Object | jQuery object.