Is it necessary to learn angular?

Source: Internet
Author: User
Let's talk about your situation. The development front-end mainly uses bootstrap, jquery, and ajax. Effect animation form verification is jq. Thinkphp is used in the background. Search for a better front-end framework some time ago and see angular. However, after learning for a while, I feel very confused. That question and answer also read my own situation.
The development front-end mainly uses bootstrap, jquery, and ajax. Effect animation form verification is jq.
Thinkphp is used in the background.

Search for a better front-end framework some time ago and see angular. However, after learning for a while, I feel very confused.
I also read that question and answer article three or four times. The main core is not to operate the DOM. However, according to angular, extending each html tag does not seem to have any advantage over jquery's html and js separation.

The second is data two-way binding, which is also of little use. Whether it is form verification or other animation effects, jq is not under pressure.

Another question is MVC. Why does angular need to be separated at the front end instead of tp mvc? What is the benefit if I want to loop?

    Under
  • In general, you can use tp to directly foreach, but angular must be written as follows:


    • {{**}}

    In this way, we can write data in Javascript. How can we allocate SQL data?

    So why is angular used by so many people?

    Reply content:

    Let's talk about your situation.
    The development front-end mainly uses bootstrap, jquery, and ajax. Effect animation form verification is jq.
    Thinkphp is used in the background.

    Search for a better front-end framework some time ago and see angular. However, after learning for a while, I feel very confused.
    I also read that question and answer article three or four times. The main core is not to operate the DOM. However, according to angular, extending each html tag does not seem to have any advantage over jquery's html and js separation.

    The second is data two-way binding, which is also of little use. Whether it is form verification or other animation effects, jq is not under pressure.

    Another question is MVC. Why does angular need to be separated at the front end instead of tp mvc? What is the benefit if I want to loop?

      Under
    • In general, you can use tp to directly foreach, but angular must be written as follows:


      • {{**}}

      In this way, we can write data in Javascript. How can we allocate SQL data?

      So why is angular used by so many people?

      Learning Angularjs is not the focus, but the focus is to learn the logic of MVVM (which will be explained later). Angular is the most mature logic solution, so many people will suggest you learn Angularjs. In fact, there are also Ember, Aurelia and so on. They are all very good MVVM frameworks.
      For example (Angularjs ):
      If jQuery is used as the column data you write, you need:

      //foo is Arrayfoo.forEach(function(eachFoo){    $ul.append('
    • ' + eachFoo + '
    • ');});

      Angularjs needs to be written on html, that is, instructions:

      
            
            
      • {{eachFoo}}

      If you do not continue to process the foo variable, it is obvious that jQuery is more convenient, but what if you need to delete the variable in foo? In jquery, two steps are required:
      First, delete the variable:

      Var index = 1; // the location of the variable to be deleted foo. splice (index, 1 );

      Second, delete the dom element:

      $ Ul. find ('li: eq ('+ index +'). remove (); // the actual operation is much more complex.

      In Angular, you only need to delete the variable specified by foo In the controller, that is, the first step of jquery above, but the writing method is a little different.

      var index = 1;$scope.foo.splice(index, 1);

      Then you don't have to worry about dom elements. It will automatically delete the dom elements corresponding to the variables. Similarly, to add a variable, you only need to push (new variable) in foo, but jQuery is different. It not only needs to push, but also append, you even need to know where the push is.

      Here, you can probably understand why so many people like Angularjs, because with it, you don't have to worry about dom elements anymore (this is a very painful thing, especially when there is a lot of data), you only need to define the command and then directly operate the variables in $ scope. This is a very comfortable and easy task.

      Back to MVVM. What is this? MVVM is actually the model view-view model, that is, the binding of data to the view. The operation data is equivalent to the operation view, and the operation view is also equivalent to the operation data, that is, the legendary two-way binding.

      Back to your question, you don't need to learn Angularjs. I think it is necessary. Regardless of the project size, anguarjs can completely replace jquery, and angularjs contains jquery (mini version, as little as possible ). It is not difficult to study. It took me about two weeks to get started. We recommend that you follow the official document to learn https://docs.angularjs.org/tutorial, which is quite well written.

      Form Verification is more advantageous for angular than jquery, because you do not have to handle the dom when a user input error occurs, you only need to define the command so that angular can handle it (it can be handled with a third-party package validator, but it is even simpler ).

      As for animation, angular is simpler than jquery, because it is written in css, which is a little different from those in fadeout of jquery. Even better, as long as css is defined, the appearance and disappearance of all your dom are animated, which is much easier than writing an animation for every dom in jquery. It is also because css animation has a GPU addition (transform3d), which is not a little smoother than jquery.

      But angular is not perfect, and you must accept some shortcomings. If your project SEO is relatively dependent, it is a little troublesome to use Angular, because view is basically operated by js, the search engine is invisible (the solution is extremely complicated), especially when route is used, it is more difficult to do SEO. In many cases, Angular is mostly used on mobile devices or apps, and is rarely used on the desktop (not completely useless, mainly because jquery currently uses too many people ).

      Extension:
      React is a little more complex than angular. It involves a virtual dom knowledge point. It directly writes html in js without writing instructions. The biggest advantage is that the execution efficiency is quite high. I was just getting started and haven't actually used it yet. I have the opportunity to study it again.

      In addition, you mentioned bootstrap, which is the UI framework and mainly responsible for the appearance. It is quite different from jquery angular.

      In addition, I wrote a cloud album, just written with jquery at the beginning, now is slowly migrating to angular, interested can look at: http://www.lazycoffee.com

      I am also new to Angularjs. Please do not repost it to avoid mistakes.

      The best thing about Angular is that it allows you to write front-end code like the back-end code.
      Template and Controller can basically implement the classic mvc form

      Why use it?
      1-low learning threshold, easy to use
      2-make the Code better maintained
      3-bidirectional binding is very convenient
      4-if you use Ionic, you cannot hide Angular.
      5-if you write mobile WebApp angular, you can load and process Sub-pages at different levels faster at a time.

      I am also working on backend php development. I want to develop a project some time ago and I want to use angular on the front end. So I learned a little about it.

      1. Good idea. It is easy to maintain by integrating mvc into front-end development.
      2. If the project is not too large, do not consider it.

      I am not a professional front-end engineer and may not be very familiar with angular, but it seems that react has been very popular for a long time. It is very cool to handle dom. If you can get started with angular, it looks good.

      Personal Opinion

      Angular is applicable to the APP-type page that uses the background write-only interface and the frontend processes the logic based on the value returned by the interface.
      You hand over the logic to the background, and most of the operations on the foreground are submitted to the background. php dynamically generates pages in this format, of course, it is unnecessary.

      Two-way data binding is very useful. You think it is useless because you have not encountered the corresponding situation. For example, you have a js two-dimensional array that you want to display in the html model in the form of a table, and the model also needs to add, delete, query, modify, and other functions to the table. After angularjs is used, you only need to perform operations on the js two-dimensional array, so that you can achieve the goal without any dom operations. However, angularjs does not deviate from the html and js Code separation specifications.

      I agree with the idea on the first floor, learn a set of frameworks, and learn more about the ideas. A lot of knowledge is the same, learningangularjsKnowledge reserves. For example, university study firstC Language,C#Later, I learnedjavaIt will feel much easier.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.