Home  >  Q&A  >  body text

angular.js - AngularJS 比 jQuery 强大吗?强大在哪

如果说 AngularJS 比 jQuery 强大,强大在哪?

PHP中文网PHP中文网2714 days ago1328

reply all(13)I'll reply

  • 阿神

    阿神2017-05-15 16:59:55

    The above answer is obviously unreasonable. It may be because I have never used ng. The main reasons why ng is more powerful than jq are:

    jquery modifies elements by manually operating the dom, and ng modifies the data and automatically synchronizes it to the dom
    For example, there is a list to display:

    <ul ng-repeat="i in list"><li>{{i}}</li></ul>
    

    ng code: $scope.list = [1,2,3], 修改list $scope.list[2] = 4
    The third li of dom’s ul will automatically become 4

    And for jq, the code needs to be:

    list[2] = 4
    $('ul').html('')
    $.each(list, function(i,v){ $('ul').append('....') })
    

    To put it bluntly, if you modify the data during ng execution, the html will automatically change. If you modify the data with jq, you still need to modify the html yourself
    Moreover, in ng, after the html (such as the value of the form input) changes, the data automatically changes, while jq still needs var data = $('input').val();

    This is called two-way binding of data.

    Of course ng is only suitable for single-page applications and is not conducive to SEO. This is another matter

    reply
    0
  • 怪我咯

    怪我咯2017-05-15 16:59:55

    These are two things with completely different concepts and are not comparable.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 16:59:55

    First of all, the two are not very comparable. The focus of jquery is to provide a variety of element selections and various methods of selecting elements to help developers quickly develop pages. But in essence, it is not a program framework. Moreover, many selector angles can be implemented directly using native tools, while Angular is more about the development convenience brought by its automatic binding of data and pages, which is more suitable for scenarios where the page has relatively few interactions and focuses more on data presentation. Use below.
    So if lz wants to compare, what we should actually compare is backbone and angular.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 16:59:55

    Most of the code in a Markdown editor that I spent a long time writing actually only implemented a little bit of AngularJS; and I quickly wrote and implemented many functions of jQuery myself.

    After reading the jQuery core code, I feel that jQuery provides a writing style, while AngularJS is truly powerful and difficult to implement by yourself. The missing corner of JS opens up a new way of thinking.

    Of course, jQuery and AngularJS focus on different things and have their own applications in their respective fields.
    Just in terms of the difficulty of implementing it yourself, AngularJS is greater than jQuery.

    jQuery focuses on code, AngularJS focuses on architecture and functionality.

    Reference: http://damoqiongqiu.iteye.com/blog/1926475 https://angularjs.org/
    http://jquery.com/

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-15 16:59:55

    Functionally speaking, these two things are not comparable at all.
    If you look at the way the entire code is written, I feel that jquery is more elegantly written. But in fact, there is no absolute, after all, everyone is different.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-15 16:59:55

    There is really no comparison. jQuery is just a class library for operating DOM, while AngularJS is an MVC (or MVVM) framework.
    AngularJS realizes the complete separation of View and data. The two-way data binding function provided by AngularJS synchronizes View all the time as long as the data is modified, and there is basically no need to manually operate the DOM.
    Of course, in addition to the two-way data binding function, AngularJS also provides routing, services, filters, templates, instructions, module management, dependency injection, unit testing and other functions.

    I don’t know if you will have an intuitive understanding of the difference between the two after saying this.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 16:59:55

    This question is like asking whether a hammer is stronger than a screwdriver. What is the strength?
    With different concepts, no one can replace the other. It’s really impossible to say who is more powerful. You can choose which one to use based on your needs. They are all very useful tools.

    Some people compare jqueryui and angularjs and think it’s silly


    Angular is a framework model for overall development. No matter what kind of framework it is, it needs favorable tools to assist its implementation. At this time, jquery plays a huge role as a tool and is a very easy-to-use Swiss Army knife, haha, so It’s called sharp jquery. Angular is a framework and jquery is responsible for work at different levels. The two-way binding of Angular’s ​​data DOM is relatively weak. Of course, many people think this is very powerful, because this feature is really convenient in weak structure and weak interaction pages. , in a page with a complex structure and strong interaction, the advantage of Angular's binding feature immediately becomes useless. There is no conflict between the two. Taking my work as an example, I understand Angular as the architectural structure of the house, including frame structure, frame-shear structure, and brick-concrete structure. I understand jquery as the decoration style of the house, including European, modern, and Southeast Asian styles. Now you understand, the two are independent, there is no conflict, and there is no selective comparison.

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-15 16:59:55

    One is the MVC framework and the other is the library. One externally reflects the design idea, and one simplifies and strengthens the native js. We can also use jq to implement our own framework. So there is no comparison.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-15 16:59:55

    AngularJS has successfully allowed Java developers to write this part better even when team members lack JS capabilities.

    A good front-end programmer will try to separate the front-end and back-end data interaction operations as much as possible. The front-end programmer only needs to provide a one-click fool-like js method for each page, and the back-end only needs to return the fixed format data according to the data template and then call it. Can ( )

    Programmers who lack js capabilities and are not proficient in DOM operations need AngularJS, an inefficient yet seemingly easy-to-use framework

    So to put it bluntly, AngularJS is a crappy solution for Java programmers who lack JS capabilities and rely heavily on frameworks.

    AngularJS is a heavyweight front-end framework, which means it is very performance-hungry and is suitable for places where page performance and interaction are not high. ;

    Summary: Programmers who don’t understand the front-end always want to bring back-end thinking into the front-end, regardless of front-end or back-end. AngularJS is a compromise solution for programmers who don’t have good front-end technical thinking

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-15 16:59:55

    Comparison is just comparison. What is stupid or not? There are too many dimensions to compare. How many programmers have to go from being familiar with jQuery to learning Angular. This process will inevitably go through the comparison between the two. There are many trends in itself. More and more people are using angular instead of jquery, which may show who is more powerful, although I prefer jQuery.

    reply
    0
  • Cancelreply