Table of Content
- Introduction
- Why do we need AngularJS?
1. Two way data bind
2. Test Driven Development
3. Unit Testing
4. Template Data Binding
5. Separation of concerns
6. Dependency Injection
- First Program
- How it works
Introduction
AngularJS is a JavaScript framework maintained by Google. It is an open-source JavaScript framework. It is completely free. It is used in Single Page Application (SPA) project. Latest version of AngularJS is 2.0 but still it is a beta version. I am not going to cover any feature of 2.0 in this article. AngularJs works on MVW framework. MVW stand for model view whatever.
Why we need Angular

(img src: jeffwhelpley.com)
Before writing the first program in Angular let’s talk about why AngularJS needed. Before Angular, jQuery is popular JavaScript library and jQuery has its own limitations. I am not going to elaborate the difference between jQuery and angular but, yes, I am going to cover some differences.
Two way binding
AnuglarJS supports two way data bind. Two way binding means if you update model then it reflects on view or you can say it updates our DOM element without any refresh.

(img src: docs.angularjs.org)
Test Driven Development
AngularJS supports Test Driven Development (TDD). TDD is an approach where we do test first and then we go for development. The benefit of implementing TDD is our requirement clear to us.

(img src: firebearstudio.com)
Unit Testing
This is a process in which we test the smallest part of our application.

(img src: optimalbi.com)
Template Data Binding
This binding populates the associate DOM element with the result of rendering template.

(img src: docs.angularjs.org)
Separation of concern
According to Wiki:

(img src: www.flexrule.com)
Dependency Injection
Dependency Injection (DI) is a pattern that implements inversion of control for resolving dependencies. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it.

(img src: antjanus.com)
First Program
Before writing any program in AngularJS first we need to download AngularJS.

Click on Download AngularJS 1

Code
- <!DOCTYPE html>
- <html>
- <head>
- <title>My First App In AngularJS</title>
- <script src="scripts/angular.min.js"></script>
- </head>
- <body ng-app style="font-family:verdana;">
- <div><input type="text" ng-model="Name"></div>
- <div style="clear:both; height:20px; width:10px;"></div>
- <div>{{Name}}</div>
- <div style="clear:both; height:20px; width:10px;"></div>
- <div ng-bind="Name"></div>
- </body>
- </html>
Let’s understand the code.
Firstly, add a reference of AngularJS.
Secondly, add ng-app directive at root. ng-app will auto bootstrap application. Some more directives used in this demo are ng-model and ng-bind. We will talk about directive in next article.
Note:
There is no difference between ng-bind and expression bind ”{{}}” performance wise. Both take the same time. Only difference is we can add some text easily in expression bind.
- <div>
- Hello, {{ Name }}
- </div>
- <div>
- Hello, <span ng-bind=" Name "></span>
- </div>
Output

Read more articles on AngularJS:

Pramod ThakurPosted Aug 18, 2016, 2:34 AM
Thanks Subash
SubashPosted Aug 18, 2016, 12:50 AM
Nice share sir
Pramod ThakurPosted Mar 28, 2016, 3:19 AM
tnx Ankur Mistry...
Pramod ThakurPosted Mar 28, 2016, 3:19 AM
thank you Vivek Kumar..
Ankur MistryPosted Mar 28, 2016, 2:13 AM
Nice share, helpful for understanding
Vivek KumarPosted Mar 23, 2016, 1:12 PM
Nice share
Pramod ThakurPosted Mar 15, 2016, 10:08 PM
tnx kalu singh rao...
kalu singh raoPosted Mar 15, 2016, 7:32 AM
Nice...
Pramod ThakurPosted Mar 14, 2016, 12:51 PM
Amit Singh thank you..
Pramod ThakurPosted Mar 14, 2016, 12:50 PM
tnx Anil Kumar Murmu
Pramod ThakurPosted Mar 14, 2016, 12:50 PM
tnx Mohammed Ibrahim
Amit Kumar SinghPosted Mar 14, 2016, 7:48 AM
Nice Share
Sreekanth ReddyPosted Mar 14, 2016, 5:59 AM
Very nice.
Anil Kumar MurmuPosted Mar 14, 2016, 5:08 AM
good one
Mohammed IbrahimPosted Mar 14, 2016, 3:59 AM
nice
Pramod ThakurPosted Mar 14, 2016, 3:10 AM
thanks Debasis Saha..
Debasis SahaPosted Mar 14, 2016, 12:45 AM
Nice share
Pramod ThakurPosted Mar 13, 2016, 11:15 AM
thank you Kashif Sohail
Pramod ThakurPosted Mar 13, 2016, 11:15 AM
thank you Abhishek Arora
Pramod ThakurPosted Mar 13, 2016, 11:13 AM
thank you Lalit Kumar..
Kashif SohailPosted Mar 13, 2016, 10:58 AM
Nice
Abhishek AroraPosted Mar 13, 2016, 9:50 AM
Great article...!!
Lalit KumarPosted Mar 13, 2016, 9:46 AM
Nice Share