AngularJS Tutorial 10:ng-model directive syntax with example

ng-model directive bind the html elements to angular app model.

Syntax with example: 

<input type="text" ng-model="name" />

Full Code:

<!DOCTYPE html>
<html>
<head>
    <script src="angular.min.js"></script>
    <script>
        var myApp = angular.module("myModule", [])

        myApp.controller("MyController", function ($scope) {
            $scope.name = "ranga";
        });
        
    </script>
    
    <title></title>
</head>

<body ng-app="myModule">
    
    <div ng-controller="MyController">
        <!-- ng-model directive bind the html elements to angular app model.-->
            <input type="text" ng-model="name" />
    </div>
    
</body>

</html>

Output:
In the browser textbox u can see 'ranga'

If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar