First Application With AngularJS

AngularJS

AngularJS is basically a structural framework. These are dynamic web applications. It is a very powerful language. AngularJS is an open source language. AngularJS language is easy and fast compared to other script languages. AngularJS is used to have Single Page Application (SAP) projects. It is very easy to update, insert and get information from our HTML document. 

There are three important parts in AngularJS,
  1. ng-aap
  2. ng-model
  3. ng-bind
ng-app: It is the first point of AngularJS to the page. It is defined to link an AngularJS Application to HTML. 

Syntax:
  1. <div ng-app="modulename">  
  2. here right code..  
  3.   
  4. </div>   
ng-model: It works to bind the values of HTML controls to the Application data.

Syntax:
  1. <element ng-model="name"></element>  
ng-bind: It is used to bind AngularJS Application data to HTML tags.

Syntax:
  1. <element ng-bind="expression"></element>  
Here is the AngularJS first program.

1

Code
  1. <!DOCTYPE html>  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3.   
  4. <head>  
  5.     <title></title>  
  6.     <script src="Scripts/angular.min.js"></script>  
  7. </head>  
  8.   
  9. <body>  
  10.     <p>Fill the TextBox</p>  
  11.     <div ng-app="App" ng-controller="myCtrl"> First Name: <input type="text" ng-model="firstName"><br> Last Name: <input type="text" ng-model="lastName"><br> Degree: <input type="text" ng-model="Degree"><br> <br> Full Description: {{firstName + " " + lastName +" "+ Degree}} </div>  
  12.     <script>  
  13.         var app = angular.module('App', []);  
  14.         app.controller('myCtrl', function($scope) {  
  15.             $scope.firstName = "";  
  16.             $scope.lastName = "";  
  17.             $scope.degree = "";  
  18.         });  
  19.     </script>  
  20. </body>  
  21.   
  22. </html>  
Output

2


Similar Articles