简体   繁体   中英

what is the jquery usage with angular js?

i want to implement Angular JS, Angular JS UI plugins and bootstrap in my ASP MVC 5 apps. Some people say Jquery is still in use in Angular JS part, so could any one here please explain when and where i would need to use JQuery in Angular Js code?

Angular doesn't include jQuery but a light-weight plugin called jq-lite . This provides a lot of the methods that jQuery does, but not all of them.

It specifically has to do with Angular.element . You can take a look at the documentation here

https://docs.angularjs.org/api/ng/function/angular.element

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.

Basically, there are a couple of pointers to keep in mind

  1. Keep all DOM logic outside of the controllers. Use custom directives on attributes for that.
  2. Instead of simulating mouse events, use their angular counterparts. Examples include ng-click and ng-mouseover . Add these directives to the elements in the form of attributes.
  3. Instead of adding classes, use ng-class
  4. If you are using jquery or jqlite, be sure to include the jquery script before the angular script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM