Improve this Doc View Source ngJq

  1. directive in module ng

Use this directive to force the angular.element library. This should be used to force either jqLite by leaving ng-jq blank or setting the name of the jquery variable under window (eg. jQuery).

Since angular looks for this directive when it is loaded (doesn't wait for the DOMContentLoaded event), it must be placed on an element that comes before the script which loads angular. Also, only the first instance of ng-jq will be used and all others ignored.

Directive Info

  • This directive executes at priority level 0.

Usage

  • as element: (This directive can be used as custom element, but be aware of IE restrictions).
    <ng-jq
      [ng-jq="string"]>
    ...
    </ng-jq>
  • as attribute:
    <ANY
      [ng-jq="string"]>
    ...
    </ANY>

Arguments

Param Type Details
ngJq
(optional)
string

the name of the library available under window to be used for angular.element

This example shows how to force jqLite using the ngJq directive to the html tag.

<!doctype html>
<html ng-app ng-jq>
...
...
</html>

This example shows how to use a jQuery based library of a different name. The library name must be available at the top most 'window'.

<!doctype html>
<html ng-app ng-jq="jQueryLib">
...
...
</html>

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.5.11/docs/api/ng/directive/ngJq