Angular JS: General Features
Angular JS: General Features
UNIT - III
INTRODUCTION:
AngularJS is an open-source web application framework.
AngularJS is a very powerful JavaScript library.
It is used in Single Page Application (SPA) projects.
AngularJS is open source, completely free, and used by thousands
of developers around the world.
AngularJS (commonly known as “Angular.js” or “AngularJS
1.X“) is a JavaScript-driven open-source front-end web application
methodology majorly maintained by Google as well as a community
of people and enterprises to tackle many of the challenges faced in
developing one-page applications.
It was originally developed in 2009 by Misko Hevery and
Adam Abrons.
It is now maintained by Google. Its latest version is 1.2.21.
AngularJS is a structural framework for dynamic web applications.
General Features
The general features of AngularJS are as follows −
Scope − These are objects that refer to the model. They act as a
glue between controller and view.
MVC is popular because it isolates the application logic from the user
interface layer and supports separation of concerns. The controller
receives all requests for the application and then works with the model to
prepare any data needed by the view. The view then uses the data
prepared by the controller to generate a final presentable response. The
MVC abstraction can be graphically represented as follows.
(a) The Model
The model is responsible for managing application data. It responds to
the request from view and to the instructions from controller to update
itself.
Angular JS Disadvantages:
1. AngularJS Library
2. Editor/IDE
3. Browser
4. Web server
AngularJS Library
To download AngularJS library, go to angularjs.org -> click download
button, which will open the following popup.
Select the required version from the popup and click on download button
in the popup.
Sublime Text
Aptana Studio 3
Ultra Edit
Eclipse
Visual Studio
Online Editor
You can also use the following online editors for learning purpose.
plnkr.co
jsbin.com
We are using our own online code editor for all the AngularJS examples in
these tutorials.
Web server
Use any web server such as IIS, apache etc., locally for development
purpose.
Browser
You can install any browser of your choice as AngularJS supports cross-
browser compatibility. However, it is recommended to use Google
Chrome while developing an application.
(3) First AngularJS Application
Let's create a simple AngularJS web application step by step and
understand the basic building blocks of AngularJS.
<html>
<head>
</head>
<body>
</body>
</html>
2. Include angular.js file in the head section (you have learned how to
download angular library in the previous section). You can take a
reference from the CDN also.
</body>
</html>
3. Here, we will be creating a simple multiplier application which will
multiply two numbers and display the result. User will enter two numbers
in two separate textboxes and the result will be displayed immediately, as
shown below.
Fir
st AngularJS Application
The following is the HTML code with AngularJS for the above multiplier
example.
Example: First AngularJS Application
<!DOCTYPE html>
<html>
<head>
<title>First AngularJS Application</title>
<script src= "~/Scripts/angular.js"></script>
</head>
<body ng-app >
<h1>First AngularJS Application</h1>
The above example is looks like HTML code with some strange attributes
and braces such as ng-app, ng-model, and {{ }}. These built-in
attributes in AngularJS are called directives.
The following figure illustrates the AngularJS building blocks in the above
example.
Template
In AngularJS, a template is HTML with additional markups. AngularJS
compiles templates and renders the resultant HTML.
Directive
Directives are markers (attributes) on a DOM element that tell AngularJS
to attach a specific behavior to that DOM element or even transform the
DOM element and its children.
Expression
An expression is like JavaScript code which is usually wrapped inside
double curly braces such as {{ expression }}. AngularJS framework
evaluates the expression and produces a result. In the above example, {{
Num1 * Num2}} will simply display the product of Num1 and Num2.
Concept Description
Model The data shown to the user in the view and with which the user interacts
Scope A context where the model is stored so that controllers, directives and expressions can access it
Data Binding Sync data between the model and the view
Module a container for different parts of an app including controllers, services, filters, directives which configure
the Injector