Published on Dec 18,2017
4.1K Views
Email Post

Today, AngularJS has become one of the most popular development frameworks primarily because of its ability to help developers create Single Page Applications (SPA) with ease. In traditional web applications, the client (browser) initiates a communication channel with the server by requesting a page. The server responds by processing the request and sending the HTML of the page back the client. If the user request for a new page, the server sends another HTML page. Even if the client asks for a small change, say a form with basic details, the entire page has to be loaded again by the server and sent back to the client.

HTML & Ajax Requests

In Single Page Applications, the entire page is loaded in one shot, and subsequent communication is carried out by the server using Ajax requests. The browser has to update only the portion of the page that has changed and there is no need to reload the entire page every time a user makes a new request.
Since the SPA approach reduces the time taken by the server to respond to user requests, web applications run faster, use less compute power, and allow User Interface (UI) developers to create more attractive, agile web pages.

Creation of Shell pages

The ‘single page’ in SPA refers to a shell page that responds to queries in the form of HTML, CSS, or JavaScript. The shell page is asynchronously rendered with the HTML, eliminating the need of back and forth travel to the server. The shell page only needs a reference to the AngularJS JavaScript library and an ng-view directive (a virtual container that allows UI developers to switch between views) to tell AngularJS where the content pages need to be rendered on the shell page.
Within the same ‘single’ page, AngularJS allows developers to provide multiple views contained within the same URL. Different sets of views can appear – one after another – within the same shell page, and each view dynamically loads as and when the user scrolls through the page.

SPA-using-AngularJS-multiple-views

The built-in AngularJS Directive — ng-app – allows developers to initialize the app, with the option of adding third-party directives as well. The ng-model Directive, on the other hand, allows you to add data binding expressions into the memory. Take a look here:

ng-directive-SPA-using-AngularJS

Globally, developers have adopted SPA using AngularJS and in all likelihood, this trend is expected to last for a while.

Got a question for us? Please mention it in the comments section and we will get back to you.

Related Posts:

Share on

Browse Categories

Comments
0 Comments