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.
Written by blackdragn
Related protips
3 Responses
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)
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.
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.