Skip to main content

Simple Data Binding Using AngularJS


In this article we will create Simple Data Binding using AngularJS. The code will automatoically display the input details in the page. To learn more about this, just follow the steps below.

Getting started:

First you will need to download & install the AngularJS here's the link https://angularjs.org/.

And this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.

Creating the Main Interface

This code contains the interface of the application. This code will render application and display the form. To do that just kindly write these block of code inside the text editor and save this as index.html.

  1. <!DOCTYPE html>
  2. <html lang = "en">
  3. <head>
  4. <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
  5. <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
  6. <script src="js/angular.js"></script>
  7. <script src="js/script.js"></script>
  8. </head>
  9. <body ng-app="myModule">
  10. <nav class="navbar navbar-default">
  11. <div class="container-fluid">
  12. <a class="navbar-brand" href = "https://www.sourcecodester.com">Sourcecodester</a>
  13. </div>
  14. </nav>
  15. <div class="col-md-3"></div>
  16. <div class="col-md-6 well" ng-controller = "myController">
  17. <h3 class="text-primary">Simple Data Binding Using AngularJS</h3>
  18. <hr style="border-top:1px dotted #000;"/>
  19. <div class="col-md-4">
  20. <textarea class="form-control" style="resize:none;" ng-model="result"></textarea>
  21. </div>
  22. <div class="col-md-6">
  23. <div style="float:left; margin:10px;">{{result}}</div>
  24. </div>
  25. </div>
  26. </body>
  27. </html>

Creating the Main Function

This code contains the main function of the application. The code will dynamically display the inputted details. To that just kindly copy and write these block of codes inside the text editor, then save it inside the js folder as script.js

  1. var myApp = angular.module("myModule", [])
  2. .controller("myController", function($scope){
  3. });

There you have it we successfully created a Simple Data Binding using AngularJS. I hope that this very simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.