What is the exact role of ng-model
in AngularJS? Can anyone explain with example? And when we can use ng-model
?
Asked
Active
Viewed 90 times
-2

svarog
- 9,477
- 4
- 61
- 77

Deepak verma
- 19
- 2
-
possible http://stackoverflow.com/questions/12419619/whats-the-difference-between-ng-model-and-ng-bind – Sa E Chowdary Dec 15 '16 at 12:42
-
1Possible duplicate of [ngModel and How it is Used](http://stackoverflow.com/questions/29550909/ngmodel-and-how-it-is-used) – pgrodrigues Dec 15 '16 at 12:46
1 Answers
0
ng-model
in angular js
is basically a directive
which binds the value of your model with the controller. Angular js Supports two way data binding which means when the value of variable changes in the model it will be reflected in the controller and vice versa. Here is a sample code which shows the two way data binding of angular js.
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="">
<p>Input something in the input box:</p>
<p>Name : <input type="text" ng-model="name" placeholder="Enter name here"></p>
<h1>Hello {{name}}</h1>
</div>
</body>
</html>
You could find the details at tutorialspoint, w3school

Nitheesh
- 19,238
- 3
- 22
- 49