(17) The JQuery framework must be loaded before angularJS. jqueryangularjs

Source: Internet
Author: User

(17) The JQuery framework must be loaded before angularJS. jqueryangularjs

If our web page only introduces the angulrjs framework (not the jQuery framework), we may encounter the following errors during usage:

Error: [jqLite:nosel] Looking up elements via selectors is not supported by jqLite! 


For example, in the following code, when we click the injector button, an error similar to the above will occur.

Error Code 1:

This is because the angular. element () API does not support selectors similar to jquery, that is, angular. element () does not support selector. It is best to introduce the JQuery framework, because it is too convenient to select elements from the jQuery framework. If you do not want to use jQuery, you can use document. querySelector () in HTML5. This API supports selector.


Code 1:


Note: If jQuery and angular are used in the page, you must first load the jQuery framework and then load angular..

The following code loads angular and then jQuery. When you click the injector button, an error is returned:

TypeError: $(...).injector is not a function


Error Code 2:


If we load jQuery first and then angular, there will be no problem. This is because if the jQuery framework is not found during angular loading, the built-in jqlite will be used, so angular cannot inject injector (), scope () and other methods into jQuery objects.

Code 2:


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.