As regards differences in implementation of Angular vs. Jquery
Angular.js is a framework.
When running Angular.js, it is loaded, where its DOM and Javascript tree is transformed into an angular application.
This is because HTML code with special characters (directives and angular filters) is compiled and angular performs a binding between Controller, Model and View (MVC standard).
So you need to understand these controllers, services, directives, etc. I understand it’s a moderate learning curve.
It would be a good option for an application that has CRUD for example.
Just include the property ng-app in the html element we want to "activate" the Angularjs:
<html ng-app>
<head>
<title>Lista de compras</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
</head>
<body>
Hello <input type="text" ng-model="yourName"/>
<h1>Hello {{yourName}}</h1>
</body>
</html>
Beyond the property ng-app (line 1), we use for Databind the property ng-model, to inform that this element will be connected to an Angularjs variable, through the yourName variable on line 8. This means that any change in the text box will update the variable value.
Every time the template is updated - either through asynchronous AJAX calling, or through direct manipulation
somewhere in the Controller code, Angular updates the data model and keeps it in sync with the View.
Among Objectives/ Characteristics:
- Abstract DOM manipulation from application logic. This improves code testing.
- Abstract the coupling between the client side and the server side of the application. This allows application development to evolve on both sides in parallel and allows code reuse.
- Guide developers through the construction of the entire application: from the design of Interface, through the writing of business rules, to the testing of the application.
Jquery is a library javascript for DOM manipulation (e.g. changing colors of an element, onclick events, animation, etc...).
When running Jquery, your code will call functions from a library, prompted by some DOM event for example.
Already to load the Jquery we insert the reference to the library: <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js">
Then we insert a jQuery function on the page so that when the page is ready we can use Jquery:
$(function() { // Quando a página estiver carregada
RealizarAlgo();
})
Among Objectives/ Characteristics:
- Resolving the incompatibility between browsers.
- Code reduction with code reuse through plugins created by other developers.
- Works with AJAX.
- Secure deployment of CSS resources.
As regards the use, found this link http://w3techs.com/technologies/comparison/js-angularjs,js-jquery
I don’t know if you can compare them directly, they are completely different things. Angular is a framework, and jQuery is not. They are usually placed on opposite sides because the purpose of jQuery is to manipulate the DOM, while in Angular views are considered static, one does not manipulate the DOM in the same way as with jQuery.
– bfavaretto
@bfavaretto I never worked with
AngularJS
, but what little I’ve seen it acts on HTML just as it is possible to do withJQuery
. So this doubt arose about the differences between the two in practice.– Paulo
I also know little about Angular, but from what I understand it works with views that are entirely replaced when needed (a view can be an element or several). With jQuery it is more common to manipulate individual elements. I was hoping someone would reply or ask to clarify. I have doubts about this closure, I don’t think Gorilla vs. Shark; maybe whale versus dolphin :)
– bfavaretto
"I’m noticing (...) by some developers" "Since some blogs encourage..." [Citation needed] :P (in other words, please link to examples if possible, as this may help to create the context necessary for this question to be answered objectively; I voted for reopening anyway, but feel that without this context the answers can ramble a lot, use different points of view, etc)
– mgibsonbr
@mgibsonbr edited the question and added 2 blogs for reference, both address some points about Angularjs quoting jQuery.
– Paulo
You even studied the plunker that jeremyzerr did? jQuery vs. Angularjs
– brasofilo
I think the angular difference for jQuery is something similar to the difference between pure PHP and a framework with not very large learning curve, one cannot expect Angular to be faster than Jquery since angular is a framework while jQuery is a JS library. I did not study angular due to lack of time, but it is worth the little I saw about it, it is worth a lot, has a very small learning curve, its use is simple, maintenance also has a great performance...
– RodrigoBorth
Just to leave my two cents here, jQuery is rather a framework. From specific field, but a framework.
– Bruno Augusto
@Brunoaugusto would not be a library no? Look here
– Math
Often, a library and a specific domain framework end up being the same thing. The biggest difference between one and the other is all the methodology. Ah! Soon I bring your trophy gold shovel :p
– Bruno Augusto