Why use the Angularjs?

Asked

Viewed 1,644 times

10

I have done a lot of research, but I can’t understand why I use Angularjs, using pages .php then bank returns, CRUD and etc. I deal directly on the pages .php, lists of bank records, insertion and such things.

Where and how can Angularjs help me? In what applications do people most use?

  • 8

    Why is it fashionable, hehehehe

  • I don’t have experience with angular, but I THINK it is best suited when you work with API. Where all the back end does is provide raw data (JSON).

  • 1

    You can share responsibilities with Angularjs, Front and Back-end are independent. You can use the same back-end that in this case will be a REST API for other purposes, such as mobile.

2 answers

17


There is a lot of opinion on the subject, I decided to answer to try an answer that does not fall into this much, so it is not very extensive. I will not stand by and say whether it is an advantage or not.

The main reason people use Angularjs (or Angular which is what everyone uses nowadays) when they decide to work with Single Page Application. That is, when you produce an application based on web technology where a single page (not so rigid) does all the operations.

So remember that the client (the page) ends up working independently and all rendering of the preview takes place in the browser (or possibly another host customer’s). Generally the server access is done through an access that provides an API instead of pre-rendered pages there (although this may also occur in some situations, at least the first access usually sends the page-application).

Another reason has already been said in comment: fashion. Many do not realize that this type of application spoils the so pursued SEO. And that there are other disadvantages in opting for it. But fashion has to do with people wearing it because others are wearing it. Some people might know why they’re using, others use because they don’t know but read some blog and think they have the same problem, she just wants to do the same in the hope that it helps her.

Of course there are advantages too, that if it is a applying in fact, and not a website, may make sense its use to facilitate certain operations, such as:

  • DOM manipulation (wider than jQuery, which by the way doesn’t even make sense anymore)
  • do data Binding
  • adopt the MVC or MVVM in a "simple"
  • use a mechanism of templating
  • among other common operations done correctly ready for use.

In thesis can be used for anything, even websites if you can live with the difficulties, but most adopt without being aware of the difficulties in this case.

9

The text below is the result of a recent period of immersion in this world of Angular for learning. I ask that the community help me to improve my understanding if there is something incorrect or absent.

Angularjs is a framework for the development of Single Page Applications (SPA).

A Single Page Application is, in a simple way, a web application composed of a single page. All the required Assets (HTML, CSS and JS) are loaded in a single load (the initial) and page components built dynamically using JS according to user actions.

The biggest advantage of a SPA is that the page becomes much more responsive and agile, making it the closest experience to a desktop application. When creating a page that requires extreme responsiveness, this may be the case for a SPA.

The applications of a SPA are the most varied and, mainly, with the large amount of frameworks that use this concept (Angularjs, React, Emberjs, Meteor ...) the trend is that more and more pages in this model appear.

Surely you have visited some page that works in this format as the page of Angular2, that of the Protractor or Gmail itself. When you click on the links available on the page, there is no other load: the components are updated on the same page. Any additional data required is obtained using AJAX.

Unlike PHP where its logic is running on the server side a SPA uses JS in a heavy way, i.e., requires more user station processing (to process JS) and communicates with a Back-End as needed.

A good 'side effect' of a SPA, in my opinion, is decoupling of the Front-End and Back-End logic. Analyze some Angular code and you will see that the page rendering tasks will be in the Front End.

The other tasks related to persistence (crud, as you mentioned), heavy data computations and others will be in a second application that will be the Back-End, usually offering a Rest API for data consumption.

Other commonly cited advantages are:

  • The Back-End does not need to save the state of the user’s navigation, leaving this to the Front-End, where usually the task is done using local resources of the user’s station (using Web Storage, for example)
  • Possibility of an application working Offline, since after downloading the Assets to the user station the application will need a Back-End only to synchronize data and other operations (Note: this brings some implications that are outside the scope of this response)

Note that this is not a universal solution but a 'case'. Many are building websites in this model by, as you said, fashion.

  • So would it be advantageous, whenever possible, to use a SPA in the development of a system? I even created a topic on the subject: http://answall.com/questions/154739/web-moderna-spa-rest?noredirect=1#comment319468_154739

  • 1

    A suggested reading to help you decide whether or not to use a SPA is http://stackoverflow.com/questions/21862054/single-page-application-advantages-and-disadvantages, and to read this article (http://adamsilver.io/articles/the-disadvantages-of-single-page-applications/). Note that some things have changed since 2014 but the points are still relevant. In my opinion, Spas shine in applications that rely heavily on external data (from a backend) at the expense of a front end with high complexity.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.