AngularJS is perfect for single page applications, what's the point?

AngularJS is ideal for single page applications (SPA). I am new to angularjs and this is the first expression I came across. What does it mean?

+4
source share
4 answers

SPA is a one-page application where the browser loads the entire page once and updates part (s) of the page based on the user's request during interaction.

Now we will look for the benefits of AngularJS,

two-way data binding: When the data changes, the view is automatically updated, which means that we do not need to reload the entire page.

Controllers:. You can limit your logic to only a specific part of the view using controllers. Which makes the scope only a reference to a specific controller. This is the brillinat method for managing SPA.

Services: These are single objects that are created only once when the application loads.

Directives: Directives are custom widgets. We create them once and use them where we need to.

Routing: Switching views based on user request.

Dependency Injection: AngularJS has a built-in dependency injection. You just need to say what you need and angular will suit you. A simple example is that you need to limit the functionality in your controller, and then simply enter your controller in the service center and execute the business logic.

MVC: Using AngularJS, we can have a Model, View, Controller architecture on the client side.

and many others.

Here are some of the reasons why AngularJS is perfect for single page applications.

Check out this great video for more details on SPA and AngularJS.

+10
source

Technically, SPA means that the page does not reload at any time in the process, nor does it transfer transfers to another page.

Using the angular JS MVC framework, you can design your application in such a way that it behaves like a SPA.

+1
source

That is, when you want to make a website containing only one page (we call it a credit page), angular -JS works well. For example, download any web editor (I recommend IUEditor), create the 'angular-js' framework and create it. The angular -js website will be created and you can use it. That is the point.

0
source

A single-page application is a web development style in which a developer first loads only one page. That's all.

Now that we know that our application is only one page, how then will we have all the dynamism of the application? What is where frameworks like Angular are.

Take the example below to illustrate - we have an application that magically updates welcome text based on user input (DOM changes)

To summarize, the following example is a one-page application:

  • Some user input required
  • Something does and overrides the DOM
  • All on one page

More complex examples will use controllers, etc. I would recommend you spend time with a tutorial, for example, at http://www.freecodecamp.com/map#angularjs

<!doctype html> <html ng-app> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> </head> <body> <div> <label>Name:</label> <input type="text" ng-model="yourName" placeholder="Enter a name here"> <hr> <h1>Hello {{yourName}}!</h1> </div> </body> </html> 
0
source

Source: https://habr.com/ru/post/956437/


All Articles