Mastering Web Application

(Rick Simeone) #1

Angular Zen


But AngularJS is a good citizen of the JavaScript community and can work hand in
hand with jQuery. Upon detecting jQuery, AngularJS will use its DOM manipulation
functionality instead of relying on jqLite.


If you plan to use jQuery with AngularJS you need to include it before
AngularJS script.

Things get more complicated if one tries to reuse any of the UI components from the
jQuery UI suite. Some of them will work just fine, but most of the time there will be
some friction. It is just that the underlying philosophy of two libraries is so different
that we can hardly expect any seamless integration. Chapter 8, Building Your Own
Directives looks closely into integrating and creating UI widgets that
can correctly work in AngularJS applications.


Apples and oranges

jQuery and AngularJS can cooperate, but comparing the two is a tricky business. First
of all, jQuery was born as a library that simplifies DOM manipulation, and as such
focuses on document traversing, event handling, animating, and Ajax interactions.


AngularJS, on the other hand, is a complete framework that tries to address all the
aspects of the modern web 2.0 applications development.


The most important thing is that AngularJS takes a completely different approach
for building UI, where the declaratively specified view is driven by model changes.
Using jQuery too often involves writing DOM-centric code that can go out of hand
as a project grows (both in terms of size and interactivity).


AngularJS' model-centric and jQuery's DOM-centric paradigms are
radically different. Seasoned jQuery developers new to AngularJS
might fall into a trap of using AngularJS with the jQuery paradigms
in mind. This results in code that "fights AngularJS" rather than
unleashing its full potential. This is why we recommend that you
skip jQuery dependency, while learning AngularJS (just not to be
tempted to fall back to the old habits and learn the AngularJS way of
solving problems).

AngularJS takes a holistic approach to modern web application development,
and tries to make a browser a better development platform.

Free download pdf