Why use AngularJS?

3

I've been researching a lot, but I can not understand why I use AngularJS, since I use pages .php so the bank returns, CRUD and etc. I deal directly in the .php pages, bank records lists, insert and such things.

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

    
asked by anonymous 18.04.2016 / 02:26

2 answers

12

There is much opinion on the subject. I decided to respond to try a response that does not fall into this. So it is not very extensive. I will not be making claims that there is controversy whether it is an advantage or not.

The main reason people use AngularJS when they decide to work with Single Page Application . That is, when you are producing an application based on web technology where a single page (not so hard) does all the operations.

So remember that the client (the page) ends up working independently and all rendering of the preview occurs in the browser (or possibly another client's host ). In general the access to the server is made through an access that provides an API instead of pre-rendered pages there (although this can happen in some situations, at least the first access usually sends the application page).

Another reason has already been said in comment. Fashion. Many people do not realize that this kind of application spoils the much-hijacked SEO . And there are other disadvantages in opting for this.

Of course there are advantages as well, that if it is a application in fact, not a website, it may make sense to use it to facilitate certain operations,

  • DOM manipulation (more broadly than jQuery)
  • make data binding
  • adopt MVC or MVVM in a simple way
  • has a templating mechanism
  • among other common operations done right ready for use.

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

    
18.04.2016 / 03:20
6

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

AngularJS is a framework for Single Page Applications (SPA) development.

A Single Page Application is simply a web application made up of a single page. All required assets (HTML, CSS, and JS) are loaded into a single load (the initial) and page components dynamically built using JS according to the user's actions.

The biggest advantage of a SPA is that the page becomes much more responsive and agile, making the experience closer to a desktop application. In the need of 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 great amount of frameworks that use this concept (AngularJS, React, EmberJS, Meteor ...) the tendency is that more and more pages in this model will emerge.

Certainly you have already visited some page that works in this format like the Angular2 page, the Protractor or Gmail itself. By clicking the links available on the page, there is no other load: the components are updated on the same page. Any additional data needed is obtained using AJAX.

Unlike PHP where your logic is running on the server side, a SPA uses JS heavily, that is, it demands more processing from the user's station (to process the JS) and communicates with a conforming Back End necessary.

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

The remaining persistence tasks (as you mentioned), heavy data computations and others will be in a second application which will be the Back End, usually offering an API Rest for data consumption.

Other commonly cited advantages are:

  • The Back-End does not need to save the user's browsing status, this being done by the Front End, where the task is usually done using local resources of the user's station (using Web Storage, for example)
  • Possibility of an application running Offline, since after downloading the assets to the user's station the application will need a Back-End just to synchronize data and other operations (Note: this has some implications that are out of scope of this response)

Note that this is not a universal solution but a 'case'. Many are building websites on this template by, like you said, fashion.

    
18.04.2016 / 03:35