Here I have taken three textboxes and bound these values at run time with the help of AngularJS. AngularJS is a powerful programming framework based on JavaScript provided by Google.
AngularJS extends HTML with new attributes. This is perfect for Single Page Applications.
What should you already know before learning the AngularJS:
- HTML
- CSS
- JavaScript(Master of web programming)
AngularJS is spread as JavaScript file and add with Script tag such as :
- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
- ng-app directive define an AngularJS application.
- ng-model directive define an AngularJS model and bind the value of HTML control to application data.
- ng-bind directives binds application data to HTML view.
Now I have shown an example to bind data with HTML using AngularJS.
I have taken a page named AngularJsTest.html andthe page looks like below,
- <!DOCTYPE html>
- <html>
- <head></head>
- <body>
- <div>
- </div>
- </body>
- </html>
- <form id="form1">
- <div>
- Name:<input type="text">
- <br>
- <br/>
- Email:<input type="text">
- <br>
- <br>
- Address:<input type="text">
- <br>
- <br>
- </div>
- </form>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Angular JS Test</title>
- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
- </head>
- <body>
- <form id="form1">
- <div>
- Name:<input type="text">
- <br>
- <br/>
- Email:<input type="text">
- <br>
- <br>
- Address:<input type="text">
- <br>
- </div>
- </form>
- </body>
- </html>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Angular JS Test</title>
- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
- <script>
- var app = angular.module('myApp', []);
- app.controller('personCtrl', function ($scope) {
- $scope.Name = "UpendraPratapShahi";
- $scope.Email = "upendra.pratap@****.com";
- $scope.Address = "Noida, India";
- $scope.EMP_Info = function () {
- return$scope.Name + " , " + $scope.Email + " , " + $scope.Address;
- }
- });
- </script>
- </head>
- <body>
- <form id="form1">
- <div>
- Name:<input type="text">
- <br>
- <br/>
- Email:<input type="text">
- <br>
- <br>
- Address:<input type="text">
- <br>
- </div>
- </form>
- </body>
- </html>
Now add define directives to the HTML controls,
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Angular JS Test</title>
- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
- <script>
- var app = angular.module('myApp', []);
- app.controller('personCtrl', function($scope)
- {
- $scope.Name = "UpendraPratapShahi";
- $scope.Email = "upendra.pratap@****.com";
- $scope.Address = "Noida, India";
- $scope.EMP_Info = function()
- {
- return$scope.Name + " , " + $scope.Email + " , " + $scope.Address;
- }
- });
- </script>
- </head>
- <body>
- <form id="form1">
- <div ng-app="myApp" ng-controller="personCtrl">
- Name:
- <input type="text" ng-model="Name">
- <br>
- <br/> Email:
- <input type="text" ng-model="Email">
- <br>
- <br> Address:
- <input type="text" ng-model="Address">
- <br>
- <br>
- <b>Employee Information :</b> {{EMP_Info()}}
- </div>
- </form>
- </body>
- </html>
Now render on browser as in the following image,

Now I have made changes in value on browser and see what happens,



kalu singh raoPosted Jul 3, 2016, 9:59 PM EDT
Nice...
Thiruppathi RPosted May 1, 2016, 9:24 PM EDT
Nice
Bhuvanesh MohankumarPosted Apr 29, 2016, 3:34 AM EDT
Nice
Ramesh JangirPosted Apr 26, 2016, 4:30 AM EDT
Good one
Gowtham RajamanickamTOP 100Posted Apr 24, 2016, 10:57 PM EDT
nice share
Vivek KumarPosted Apr 17, 2016, 6:09 AM EDT
Good one.
Debasis SahaTOP 100Posted Apr 16, 2016, 2:06 AM EDT
Nice one..
Kuppurasu NagarajTOP 100Posted Apr 9, 2016, 6:40 AM EDT
Nice article..
Vignesh ManiTOP 100Posted Apr 5, 2016, 4:24 AM EDT
good one