Reputation: 4054
Based on the AngularJS document
https://docs.angularjs.org/api/ng/function/angular.element
It says
If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite."
Does this means that we can go ahead and include JQuery JS files use the JQuery selectors like angular.element("body").css({}) and use the functions?
I tested that it is working fine, but I want to know
Is there any official document/wiki which recommends/not-recommends the combination of AngularJS+JQuery
Did anyone faced a big performance issue when combining this two?
Upvotes: 4
Views: 5697
Reputation: 3104
JqLite is a subset of the jquery functions. You have use jQuery if you wanna do DOM manipulation or use modules as angular-bootstrap.
Upvotes: 0
Reputation: 2238
AngularJS is great for that. It actually runs on its side and does not interfere with other libraries. You are right, you can use angular.element("body").css({})
and you are actually using jQuery just as you would with $
.
The performance will be the jQuery performance hit. So it depends how you use it. There is no performance hit in the combining of the two.
I almost always use the two together and it's a breeze.
You should definitely try to do things the angular way when possible though. Do not use .on('click')
but ng-click, etc... You should not have to use more than what jQlite and Angular is offering in most cases if you do things right.
Upvotes: 3