Sunday, 6 December 2015

Getting Started with AngularJS


AngularJS Tutorial

AngularJS is a Superheroic Javascript MVW Framework for building Single Page Application (SPA) and dynamic apps. Here MVW stands for Model View Whatever(that may be Model View Controller architecture or Model View View-Model architecture or MV*).  AngularJS is developed and maintained by Google.

In this tutorial Series, We will cover the following topics:
AngularJS Tutorials

Let's create our first Hello World application using AngularJS:

Go to https://angularjs.org/ and click on the Download button.
AngularJS Download
After that, a modal pop-up comes on screen. Under branch, Select 1.4x (stable) version and Select a uncompressed version of AngularJS which is best for debugging and development purpose (Select Minified version of the AngularJS for deploying your application but only if you can't use Google's CDN. The zipped version of the AngularJS contains both the builds of AngularJS, as well as documentation.)
AngularJS Download
Click on Download button.
AngularJS Download
Add Script folder in the root directory of your application and Add your downloaded Angular script in that folder.
Solution Explorer AngularJS
If you are using Visual Studio IDE, then you can also add AngularJS in your application using Nuget Packets. Right click on your project from Solution Explorer and Click on Manage Nuget Packages.
AngularJS Nuget
Search for AngularJs in Manage Nuget Packages then Click on Install for installing/Adding AngularJS in your project.
AngularJS Nuget Package Manager
Now Add angularjs script in your application. After that add ng-app directive in your application. ng-app directive can be added at document level or body level or at Div level. ng-app Directive defines angular application and used for loading various angularjs modules in the application. After that Add double curly brace notation {{ }} to bind expressions to elements is built-in Angular markup.
Hello World AngularJS Example
Code:
<!DOCTYPE html>
<html ng-app>
<head>
    <title>Angular Hello World Application</title>
    <script src="Script/angular.js"></script>
</head>
<body>
    {{4+4}}
</body>
</html>
Save and Run your application. You will see the expression inside of Markup/Template ({{}}) is evaluated.
AngularJS Basics

Let's Create Hello World Application.
Add a textbox with ng-model directive. ng-model directive binds HTML control with a model/property which is used in Angular Application. We used ng-model property for displaying the value of HTML control with the help of {{name}} Template.
Hello World AngularJS Example
Code:
<!DOCTYPE html>
<html ng-app>
<head>
    <title>Angular Hello World Application</title>
    <script src="Script/angular.js"></script>
</head>
<body>
    <input type="text" ng-model="name"/><br />
    <p>Hello {{name}}!</p>
</body>
</html>
Save and Run the Application.
AngularJS Hello World Demo
We can also do the same thing using ng-bind directive in our application. ng-bind directive binds the model value to the HTML control/View.
Code:
<!DOCTYPE html>
<html ng-app>
<head>
    <title>Angular Hello World Application</title>
    <script src="Script/angular.js"></script>
</head>
<body>
    <input type="text" ng-model="name"/><br />
    <p>Hello <span ng-bind="name"></span>!</p>   
</body>
</html>
Hope you like it.
Thanks.
[Download Source Code via Google Drive]

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Excellent post. Your step by step process is really useful. Keep sharing more like this.
    Regards,
    Angularjs Training | Angularjs Training in Chennai

    ReplyDelete

Subscribe Now

Popular Posts

Contact us

Name

Email *

Message *

Subscribe us on YouTube

Like us on Facebook

Follow us on Google+