Last Updated: September 09, 2019
·
711
· blackdragn

angular & jquery

If you use Angular along with jQuery, always ensure, that you include jQuery before Angular.

Doing otherwise my produce annoying issues, as angular will use internal mini-jQuery implementation, called jqLite.
I've discovered this the hard way, when I realized that UIKit's datepicker does not update angular model.

3 Responses
Add your response

good point, but the best is to not use jQuery at all :)

I'm trying to actively avoid having to avoid it on my Angular APP, since it removes the temptation to hack the DOM (which is what we do all time with jQuery)

over 1 year ago ·

Yes, you are right. I would never use jQuery inside my own Angular project. But right now I chose to rely on third-party components framework (UIKit) which is depends on jQuery.

over 1 year ago ·

These myth of AngularJS vs jQuery battle spreads around like a virus.

Why you can and PROBABLY SHOULD use jQuery along AngularJS:

jQuery serves completely different purpose then AngularJS. AngularJS is a framework that gives structure for your app. jQuery is DOM manipulation library.

AngularJS uses jQuery / jqLite underneath for it's native directives (all ng-*), cause jQuery does DOM manipulation well.

So yes, you should use jQuery. What is bad practice is doing DOM manipulation (using jQuery or whatever) inside controllers / services. You should always do DOM manipulation only in directives.

over 1 year ago ·