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?
1 Answer
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
- Keep all DOM logic outside of the controllers. Use custom directives on attributes for that.
- Instead of simulating mouse events, use their angular counterparts. Examples include
ng-clickandng-mouseover. Add these directives to the elements in the form of attributes. - Instead of adding classes, use
ng-class - If you are using jquery or jqlite, be sure to include the jquery script before the angular script.