• We just launched and are currently in beta. Join us as we build and grow the community.

Simple Data Binding Using AngularJS

iRek

Script Execution Specialist
I Rep
0
0
0
Rep
0
I Vouches
0
0
0
Vouches
0
Posts
61
Likes
41
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
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!!


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

331,765

331,773

Top