ng-model
ng-model directive defines the model/variable to be used in AngularJS Application.
The ng-model directive is used for two-way data binding in AngularJS. It binds <input>, <select> or <textarea> elements to a specified property on the $scope object. So, the value of the element will be the value of a property and vica-versa.
In following example, we've defined a model named "name".
<div ng-app = "">
...
<p>Enter your Name: <input type = "text" ng-model = "name"></p>
</div>
Example: ng-model
<html >
<head>
<script src="angular.min.js"></script>
</head>
<body ng-app>
<h2>Directive ng-model</h2>
<input type="text" ng-model="name" />
<div>
Hello {{name}}
</div>
</body>
</html>
Note: -Variables initialized in ng-init are different from the properties defined using ng-model directive. The variables initialized in ng-init are not attached to $scope object whereas ng-model properties are attached to $scope object.
For
More Explanation
&
Online Classes
More Explanation
&
Online Classes
Contact Us:
+919885348743
+919885348743