Unit 4 - Building Single Page App With Angular Js
Unit 4 - Building Single Page App With Angular Js
What is AngularJS?
AngularJS is a platform for making dynamic web pages. It is a
framework of javascript that is structural too. AngularJS is one of the
parts of MEAN stack technology, nowadays very popular consist of
four parts.
MongoDB which is a NoSQL database
Express.js which is the server of a web application
Angularjs for the front end part
Node.js used for back-end purpose
Features of AngularJS?
i. Not browser specific
It can run on all major browsers except internet explorer 8.0 and
smartphones including Android and ios based phones/tablets.
ii. Code Less
A programmer has to write less and can perform more functionality
with the same code.
iii. Productivity
A user interface is created in a simple way and that too fast also
because of strong template syntax.
iv. Speed and performance
Speed is fast as angular apps code loads quickly due to code splitting.
v. Dependency Injection
This built-in injection helps in developing the application easily as
well as it is easy to understand.
v. Deep Linking
It allows bookmarking the web page. The page gets saved by its URL
without getting its state change.
vi. Routing
Routing allows the switching between views.
Paypal
Jetblue
Istock photo
Weather
lego
Netflix
Architecture of AngularJS?
Advantages of AngularJS
i. Open Source
AngularJS create single page application, which can work fast and it is user-
friendly.
JavaScipt and HTML both are the only prerequisites to learn AngularJS.
v. Easy to Customize
It is easy to customize as one can create its own directives too in it.
vi. Google Supported
AngularJS has the support of Google, a large community. One can fully
relax about the regular updates as well as its performance should also get
better.
Limitations of AngularJS
Less Secure
It is not secure because there is no server authorization and
authentication in angular so one cannot verify the identity in it.
Security is one of the major concerns in today’s world technology is
expanding rapidly so as the security concerns as it is necessary that
your data should remain secure.
Only Emphasize on Javascript
It is just a single static page if its javascript side gets hidden.
Memory Leakage
Also, it is a framework of javascript and there is an issue of memory
leak in javascript which makes its performance low.
Not Supported Everywhere
AngularJS does not support internet explorer 8.0
What is Data Binding?
Data binding is the synchronization of data between business logic
and view of the application. It serves as a bridge between two
components of angular that is model part and view part. Data Binding
is automatic and provides a way to wire the two important part of an
application that is the UI and application data.
Whenever some changes are done at the model side it is reflected at
view side too and vice versa is also possible. This happens so rapidly
to make sure that view and the model part will get update all the time.
AngularJS Expressions?
In AngularJS, expressions are used to bind application data to HTML.
AngularJS resolves the expression, and return the result exactly where
the expression is written.
Expressions are written inside double braces {{expression}}. They
can also be written inside a directive:
AngularJS Controllers?
The controller in AngularJS is a JavaScript function that maintains
the application data and behavior using $scope object.
You can attach properties and methods to the $scope object inside
a controller function, which in turn will add/update the data and
attach behaviours to HTML elements. The $scope object is a glue
between the controller and HTML.
Components also offer great help in making sure the design across the
application is consistent.
Dependency Injection?
AngularJS Dependency injection defines, how the various
components of the software are dependent on each other. Instead of
hard-coding a component within another component, a component is
given their own dependencies using dependency injection.
AngularJS Filter?
AngularJS filter is a tool, which we can use to format the data. With this
filter, the user can see and modify according to the requirement. It is
added in angular to format the data that is being displayed on the view
part.
Syntax of Filter
With pipe character (|), we can add filters in angularJS. Filters can club
with the expression as well as a directive.
Example: {{name | uppercase}}
Here, a name is the expression and uppercase is the built-in filter provided
by angular. It converts the name in uppercase in view part.
AngularJS Tables?
The ng-repeat directive is perfect for displaying tables.
AngularJS Forms & Forms validation?
Forms are an integral part of a web application. Practically every
application comes with forms to be filled in by the
users. Angular forms are used to log in, update a profile, enter
sensitive information, and perform many other data-entry tasks. In
this article, you will learn about how to create a form and validate the
information filled.
Template-Driven Approach
Reactive Approach
Template-Driven Approach
Form Control
Form Control is a class that enables validation. For each input field,
an instance of this class is created. These instances help check the
values of the field and see if they are touched, untouched, dirty,
pristine, valid, invalid, and so on.
Form Group
Form Group class represents a group of controls. A form can have
multiple control groups. The Form Group class returns true if all
the controls are valid and also provides validation errors, if any.
AngularJS AJAX?
AJAX is the short form of Asynchronous JavaScript and XML. AJAX
was primarily designed for updating parts of a web page, without
reloading the whole page. The reason for designing this technology
was to reduce the number of round trips which were made between
the client and the server and the number of entire page refresh which
used to take place whenever a user required certain information.
$resource
$http
AngularJS provides a $http service for reading data from remote
servers. It is used to retrieve the desired records from a server.
AngularJS requires data in JSON format. Once the data is ready, $http
gets the data form server in the following manner: