AngularJS is a very powerful and most emerging JavaScript Framework.It is used in Single Page Application (SPA) projects. It extends HTML DOM with additional attributes and makes it more responsive to user actions. AngularJS is open source, completely free, and used by thousands of developers around the world.
If you want to learn AngularJS, you must have an understanding of HTML, CSS, JavaScript and AJAX, etc.
Overall, AngularJS is a framework to build large scale and high performance web application while keeping them as easy-to-maintain.
On top of everything, AngularJS applications can run on all major browsers and smart phones including Android and iOS based phones/tablets.
When you execute the above sample program its out will be look like:
When the page is loaded in the browser, following things happens:
HTML document is loaded into the browser, and evaluated by the browser. AngularJS JavaScript file is loaded, the angular global object is created. Next, JavaScript which registers controller functions is executed.
Next AngularJS scans through the HTML to look for AngularJS apps and views. Once view is located, it connects that view to the corresponding controller function.
Next, AngularJS executes the controller functions. It then renders the views with data from the model populated by the controller. The page is now ready.
If you want to learn AngularJS, you must have an understanding of HTML, CSS, JavaScript and AJAX, etc.
Brief History of AngularJS
AngularJS is an open source web application framework. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now officially supported by Google. According to official documentation of AngularJS its definition is:
"AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you currently have to write. And it all happens within the browser, making it an ideal partner with any server technology."
AngularJS Features
- AngularJS is a powerful JavaScript based development framework to create RICH Internet Application(RIA).
- AngularJS provides developers options to write client side application (using JavaScript) in a clean MVC(Model View Controller) way.
- Application written in AngularJS is cross-browser compliant. AngularJS automatically handles JavaScript code suitable for each browser.
- AngularJS is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache License version 2.0.
Overall, AngularJS is a framework to build large scale and high performance web application while keeping them as easy-to-maintain.
Advantages of AngularJS
- AngularJS provides capability to create Single Page Application in a very clean and maintainable way.
- AngularJS provides data binding capability to HTML thus giving user a rich and responsive experience
- AngularJS code is unit testable.
- AngularJS uses dependency injection and make use of separation of concerns.
- AngularJS provides reusable components.
- With AngularJS, developer write less code and get more functionality.
- In AngularJS, views are pure html pages, and controllers written in JavaScript do the business processing.
Advantages of Components
The AngularJS framework can be divided into following three major parts −
- ng-app − This directive defines and links an AngularJS application to HTML.
- ng-model − This directive binds the values of AngularJS application data to HTML input controls.
- ng-bind − This directive binds the AngularJS Application data to HTML tags.
AngularJS Setup
You really do not need to set up your own environment to start learning AngularJS. Reason is there is lot of AngularJS environment online, so that you can execute all the available examples online at the same time when you are doing your theory work. This gives you confidence in what you are reading and to check the result with different options. You can modify the samples and execute it to see your expected results. However if you want to setup the environment at your local machine then you to download AngularJS library from below official site:
https://angularjs.org
The latest current stable version of angularJS is v1.6.6.
AngularJS Example
Now let us write a simple example using AngularJS library. Let us create a simple HTML file AngularWorld.html as below:
<!doctype html> <html> <head> <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.min.js"></script> </head> <body ng-app = "myapp"> <div ng-controller = "HelloController" > <h2>Welcome {{helloTo.title}} to learn AngularJS!</h2> </div> <script> angular.module("myapp", []) .controller("HelloController", function($scope) { $scope.helloTo = {}; $scope.helloTo.title = "naeemgik"; }); </script> </body> </html>
Now lets explain the above code line by line;
In order to include the angularJS file in your page, we have included it using CDN access like:
<head> <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.min.js"></script> </head>
Next we tell what part of the HTML contains the AngularJS app. This done by adding the ng-app attribute to the root HTML element of the AngularJS app. You can either add it to html element or body element as shown below:
<body ng-app = "myapp"> </body>
The view part of the above example is:
<div ng-controller = "HelloController" > <h2>Welcome {{helloTo.title}} to learn AngularJS!</h2> </div>
ng-controller tells AngularJS what controller to use with this view. helloTo.title tells AngularJS to write the "model" value named helloTo.title to the HTML at this location.
The controller part of the above example is:
<script> angular.module("myapp", []) .controller("HelloController", function($scope) { $scope.helloTo = {}; $scope.helloTo.title = "naeemgik"; }); </script>
This code registers a controller function named HelloController in the angular module named myapp. The controller function is registered in angular via the angular.module(...).controller(...) function call.
The $scope parameter passed to the controller function is the model. The controller function adds a helloTo JavaScript object, and in that object it adds a title field.
When you execute the above sample program its out will be look like:
Welcome naeemgik to learn AngularJS!
When the page is loaded in the browser, following things happens:
HTML document is loaded into the browser, and evaluated by the browser. AngularJS JavaScript file is loaded, the angular global object is created. Next, JavaScript which registers controller functions is executed.
Next AngularJS scans through the HTML to look for AngularJS apps and views. Once view is located, it connects that view to the corresponding controller function.
Next, AngularJS executes the controller functions. It then renders the views with data from the model populated by the controller. The page is now ready.
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete
ReplyDeleteThanks for sharing this information, this is useful to me...
Services and package prices may vary depends on your business needs and volume of transactions.
Accountant Scottsdale Arizona
Bookkeeping Scottsdale Arizona
This post is really nice and informative. The explanation given is really comprehensive and informative..
ReplyDeleteHire Angular Developer in India
I really enjoy the blog article.Much thanks again.
ReplyDeletesharepoint training
sharepoint online training
Nice Article!!! thanks for it...
ReplyDeleteWhy Machine Learning is Important
Why Machine Learning
Nice Post!!! thanks for sharing this information with us.
ReplyDeleteWhy is DevOps so popular?
What is DevOps?
This article is very attractive. Those who need this information, it's very informative and understandable for those all. Thanks for this information. Hire Angular Developer
ReplyDeleteI would like to say thanks to you , I enjoy reading this blog and found very useful for me. I really admire your words and try to understand your deep thoughts. If you want to develop AngularJS website than visit to CodersNews. We drew up a list of Top 10 AngularJS Development Companies.
ReplyDeleteThanks for sharing this informative article on What is AngularJS and Why it is considered as an emerging JavaScript Framework? If you want to Angularjs development company for your project. Please visit us.
ReplyDelete