WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS Introduction


AngularJS is a JavaScript framework. It very well may be added to a HTML page with a <script> tag.

AngularJS broadens HTML qualities with Directives, and ties information to HTML with Expressions.


AngularJS is a JavaScript Framework

AngularJS is a JavaScript system. It is a library written in JavaScript.

AngularJS is dispersed as a JavaScript record, and can be added to a site page with a content tag:

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

AngularJS Extends HTML

AngularJS broadens HTML with ng-directives.

The ng-app order characterizes an AngularJS application.

The ng-model order ties the estimation of HTML controls (input, select, textarea) to application data.

The ng-bind order ties application information to the HTML see.

AngularJS Example

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="">
  <p>Name: <input type="text" ng-model="name"></p>
  <p ng-bind="name"></p>
</div>

</body>
</html>
Try it Yourself »

Example explained:

AngularJS begins consequently when the website page has loaded.

The ng-app order reveals to AngularJS that the <div> component is the "owner" of an AngularJS application.

The ng-model order ties the estimation of the info field to the application variable name.

The ng-bind mandate ties the innerHTML of the <p> component to the application variable name.


AngularJS Directives

As you have just observed, AngularJS orders are HTML traits with a ng prefix.

The ng-init order introduces AngularJS application variables.

AngularJS Example

<div ng-app="" ng-init="firstName='John'">

<p>The name is <span ng-bind="firstName"></span></p>

</div>
Try it Yourself »

Alternatively with substantial HTML:

AngularJS Example

<div information ng-app="" information ng-init="firstName='John'">

<p>The name is <span information ng-bind="firstName"></span></p>

</div>
Try it Yourself »

You will gain proficiency with significantly progressively about mandates later in this tutorial.


AngularJS Expressions

AngularJS articulations are composed inside twofold props: {{ articulation }}.

AngularJS will "output" information precisely where the articulation is written:

AngularJS Example

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="">
  <p>My first articulation: {{ 5 + 5 }}</p>
</div>

</body>
</html>
Try it Yourself »

AngularJS articulations tie AngularJS information to HTML indistinguishable route from the ng-bind directive.

AngularJS Example

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="">
  <p>Name: <input type="text" ng-model="name"></p>
  <p>{{name}}</p>
</div>

</body>
</html>
Try it Yourself »

You will become familiar with articulations later in this tutorial.


AngularJS Applications

AngularJS modules characterize AngularJS applications.

AngularJS controllers control AngularJS applications.

The ng-app order characterizes the application, the ng-controller order characterizes the controller.

AngularJS Example

<div ng-app="myApp" ng-controller="myCtrl">

First Name: <input type="text" ng-model="firstName"><br>
Keep going Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}

</div>

<script>
var application = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.firstName= "John";
    $scope.lastName= "Doe";
});
</script>
Try it Yourself »

AngularJS modules characterize applications:

AngularJS Module

var application = angular.module('myApp', []);

AngularJS controllers control applications:

AngularJS Controller

app.controller('myCtrl', function($scope) {
    $scope.firstName= "John";
    $scope.lastName= "Doe";
});

You will become familiar with modules and controllers later in this tutorial.