Single Page Application Using AngularJS Orang India
Single Page Application Using AngularJS Orang India
Abstract— Single Page Application (SPA) is composed of In modern era of web technology most of the websites
individual component that can be replaced or updated are using SPA which is a web application that sits on one
independently, without refreshing whole page so that the single page like any other desktop application. In SPA all
entire page does not need to be reloaded on each user action, the component like CSS, images, scripts and any other
which saves bandwidth as well as no loading of external files
every time when page is loaded, such as images or CSS files,
required resources are loaded at one time at the initial page
etc. The purpose behind this is to make the subsequent page load and then appropriate content/components gets loaded
loads very fast as compared to traditional Request-Response dynamically depending on the user interaction. Once the
cycle. SPA's written by using JavaScript, HTML5, AJAX are user has loaded an initial slim version, after that every
getting the likes of developers to build their web applications subsequent request will take very less amount of time
and some frameworks like AngularJS which are built on top because it is now refreshing that particular part or region of
of the JavaScript are making the life of developers very easy. a page rather than reloading an entire page. The control
The idea behind using AngularJS in web application is to remains on one page till the user is on that website and that
make your web application modular and easy to maintain. single page communicate with the server behind the curtain.
AngularJS brings MVC (Model View Controller) capability to
your application. After using minified and compressed files in II. SINGLE PAGE APPLICATION (SPA)
your application, the size reduces to some KBs which will
results in faster loading of pages. The SPA is a web application that fully loads all of the
resources in initial request and then the page components
Keywords— Single Page Application, AngularJS, Web Application. are replaced by other component depending on user
interaction. When we compare SPA with traditional web
I. INTRODUCTION application, we can see there exist an analogy between
The traditional websites which were introduced in early ‘states’ of SPA and ‘web pages’, navigation of ‘web
days of Internet had the sheer purpose of serving static pages’ in traditional web application is analogous to ‘state’
pages (content) to its client, which included content like navigation in SPA.
images, CSS, JavaScript, etc. as the years went people
A. Definition
started using websites to publish their business and explore
it to world, by the introduction of e-commerce, the need of “Single Page Application (SPA) is composed of
providing current status of business did rise and that individual components that can be replaced/updated
requirement lead to serving the dynamic pages which were independently, without refreshing/reloading whole page so
the mirror image of live status of business. Technologies that the entire page needs not to be reloaded on every user
like Asynchronous JavaScript and XML (AJAX) were used action.”
to dynamically load the data from database. AJAX helped 1) Individual Components: Entire page is divided into
to introduce dynamic content to web pages, However, using smaller components that interact with each other.
AJAX we can built desktop applications, So to achieve
same user experience on mobile applications, Single Page 2) Replaced/Updated: A component/region/part of a
Application have been developed. We can build Single page replaced/updated with any changes on user requests.
Page Application with JavaScript too, but development and 3) Refreshing/Reloading: The entire page never
maintenance of front end using JavaScript is more complex. reloaded/refreshed, rather new content is loaded in some
Frontends with AngularJS is easy to develop and maintain, part or section as per new data.
since AngularJS frontend is broken down into 3
components Model, View and Controller (MVC). 4) User actions: Single Page Application is responsible
In the traditional approach, when user dose any for handling all user inter actions such as button click, input
interaction with a page, like button click then new page is from keyboard etc. very fast and hence leads to very fluid
loaded and generated from scratch to display a response on user interface.
user’s window. This requires more bandwidth as well as SPA allows more flexible and elegant way of dealing
time. with data. Refreshing particular part or a section of a page
without refreshing an entire page is main goal that SPA is
www.ijcsit.com 2876
Madhuri A. Jadhav et al, / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 6 (3) , 2015, 2876-2879
serving, but all this flexibility requires more interactive In SPA AngularJS,
interface and this leads to better user experience. Client makes initial request to open a particular
When we build SPA with JavaScript front end becomes website or application.
very complex. In bigger projects many developers work Server respond with HTML pages along with images,
collaboratively to build front end. If the code is very CSS, script files, and other external resources.
difficult to understand because of no separation of layouts Now when client does any interaction like button click
and business logic then maintenance of that code becomes on input from keyboard with a page, it makes a new
very difficult. This issue of maintenance of code of bigger request to a server.
projects is solved if that Single Page Application is build Server now responds with only user’s action result not
with AngularJS. Since AngularJS divides the front end into the entire HTML page again. That is server responds
3 parts. with a JSON (JavaScript Object Notation) which
Model includes only result of user’s action.
View At client side that page is not reloaded rather a
Controller particular part of a page is replaced/updated with that
Code that is easy to read and understand becomes a key response. Hence very less bandwidth as well as time is
to achieve high efficiency and good quality as well as leads required for this Client-Server Request-Response
to fluid user interface. Cycle. This leads to very fluid user interface.
B. Client-Server Request-Response Cycle
C. SEO in SPA:
In a traditional approach,
Client makes initial request to open a particular Search Engine Optimization (S.E.O.) is the process of
website or application. increasing your web site’s page rank so that more and more
Server respond with HTML pages along with images, traffic can come to your web site. The content build by
CSS, script files, and other external resources. SPA’s is dynamic and search engines have difficult time
When client does interactions with a page like button processing them this can result into poor page rank. To
click or input from keyboard, it makes a new request make your SPA S.E.O. friendly you should create HTML
to server. snapshots and regular maintenance is required. Following is
Server again responds with a whole HTML page not a the basic overview of how search engine optimization
particular part of a page. works,
At the client side that page is reloaded and hence Crawler will look at some URL.
requires more time for these Client-Server (http://mydomain.com/myseo#key=value)
interactions. This leads to more bandwidth and The crawler request web server to fetch the content of
unsatisfied user experience. that URL.
Web server returns the HTML snapshot to crawler.
HTML snapshot is processed by the crawler.
Search result shows original URL.
III. ANGULARJS
AngularJS is an open source JavaScript framework
maintained by Google and community which can help
developers to create single page applications. Its purpose is
to help developing the web applications with model-view-
controller (MVC) capability in an effort to make
development, maintaining and testing easier. SPA is getting
popular nowadays and the technology like AngularJS aids
to create such applications.
AngularJS helps to create web applications which are
based on HTML, CSS, JavaScript. AngularJS brings the
MVC capability to the web application and hence making it
more modular and easy to develop, maintain and test.
AngularJS introduces additional tags which are called as
directives. These directives are prefix with ‘ng-’ and the
goal of directive is to bind the data to the view/templates
through controller. AngularJS controllers are written in
JavaScript which add the business logic to views which are
nothing but HTML pages.
SPA is fully loaded in initial load and only page
Fig. 1 Client-Server Request-Response Cycle regions/sections are replaced or updated with new page
fragments loaded from server on demand. AngularJS helps
to create such applications easily. AngularJS is fully client
www.ijcsit.com 2877
Madhuri A. Jadhav et al, / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 6 (3) , 2015, 2876-2879
www.ijcsit.com 2878
Madhuri A. Jadhav et al, / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 6 (3) , 2015, 2876-2879
app.controller('myctrl',function($scope){
/* business logic goes here. */ });
www.ijcsit.com 2879