AngularJS Introduction

AngularJS is one of the best platform that enable developers to build structured web applications that are robust and easily to understood.

AngularJS is a powerful Javascript framework to provide complete client-side solution, specially when you building single-page web applications. AngularJS introduce new attributes to extend the HTML controls features.

This tutorial will explain you how to use AngularJS, its advantages and start writing AngularJS code from scratch.

It's data binding and dependency injection reduce extra overhead of code that otherwise have to write. AngularJS is open source and absolutely free to use only you need to include 'https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js' file.

Why AngularJS?

AngularJS is based on MVC framework that defines how to oganize your web application. Your application is defined with modules that can depend from one to the others. It extend HTML control features by attaching directives to web pages with new attributes and expressions in order to define very powerful templates directly in your HTML. The controllers encapsulates the behavior of application. AngularJS helps to structure and test your Javascript code very easily.

AngularJS Advantages

  • Reusable template creation is easy.
  • Two way data binding to any element is easy, where changing data will automatically change element and changing element will change the data.
  • You can directly call the code-behind code in your html.
  • Forms validation before submitting it without writing a single line of code.
  • Allows structure code writing, where code is divided into modal, view and controler which is easy to maintain.
  • AngularJS allows you to write basic flow end-to-end testing, unit-testing, ui mocks.

Developing an AngularJS Application From Scratch

AngularJS applications are a combination of HTML and JavaScript, so the first thing you need an HTML page:

<html>
<head>
<title>My first AngularJS code</title>
</Script>
</head>
<body>

</body>
</html>

Now, you need to include the AngularJS file in the HTML page so you can use use all attributes of AngularJS:

<html>
<head>
<title>My first AngularJS code</title>
<Script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</Script>
</head>
<body>

</body>
</html>

Now, you need to specify AngularJS section in your HTML page. To do this you need to add ng-app attribute to the root element of the section where you want to add AngularJS. Typically, root element can be HTML, BODY or DIV element of page. Below example shows ng-app attribute added in HTML tag.

<html ng-app>
<head>
<title>My first AngularJS code</title>
<Script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</Script>
</head>
<body>

</body>
</html>

Now, you have to add a HTML input text element that contains ng-model attribute. In below example contains h1 HTML element with AngularJS expression {{ myName }} which tells AngularJS to insert the model value myName into the HTML at that location. This will bind both elements, if user insert any value in text box it will automatic update the value in HTML h1 element.

<html ng-app>
<head>
<title>My first AngularJS code</title>
<Script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</Script>
</head>
<body>
<p>Input string in below box:</p>
<input ng-model="myName" type="text"  placeholder="Your name">
<h1>Hey  {{  myName  }}</h1>
</body>
</html>
Try Now

See Also

AngularJS Built-in Filters
AngularJS Built-in Directives
AngularJS Expression
AngularJS Built-in Events
AngularJS Scope Methods
AngularJS Built-in Services
AngularJS Controller Inheritance
AngularJS Custom Directives


 
 
SHARE THIS IF YOU LIKE!
submit to reddit

SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.