jquery in the Angularjs

Source: Internet
Author: User
Tags jquery library


Jqlite: A Tribute to jquery

In the DOM operation, no one is better than jquery. Angularjs in a special way to show respect to jquery: The built-in compact version of Jquery-jqlite.

    like jquery, Jqlite is compatible with multiple browsers.

    **jqlite** is provided as a ' angular.element ' interface, compatible with a subset of the jquery API. The element objects in all APIs in Angularjs are not pure DOM objects, but are encapsulated by Jqlite.




problems with selectors

From a developer's perspective, the most obvious simplification of jqlite is that it does not support selectors. You can only pass a DOM object to angular.element. It looks like Angularjs this part of the functionality to browser native support, and we can get a DOM object using the browser's queryselector first:

var TPL = document.queryselector (' #clock ');
Angular.element (TPL). Text (...);

compatibility of jquery libraries



If you don't want to use jqlite for some reason, you can also introduce the jquery library before Angularjs. ANGULARJS automatically upgrades Jqlite to Jquery,angular.element equals $. This allows you to use a familiar selector.



Methods of extension



Jqlite includes some additional methods to accommodate the ANGULARJS framework:



Controller (name)-Gets the controller object corresponding to the element



Injector ()-Gets the injector object corresponding to the element



Scope ()-Gets the scope object corresponding to the element



Isolatescope ()-Gets the isolation scope object corresponding to the element, if any.



Inheriteddata ()-Same as data (), but if the current element does not have the specified data, it continues to look for the parent node.



Extended Events



Jqlite also provides a $destroy event that, when the DOM object is removed from the DOM tree, triggers the event to be triggered by the ANGULARJS to order some cleanup work.



This article turns from: http://www.hubwiz.com/class/54f3ba65e564e50cfccbad4b


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.