Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavarePart 6.4-ng-model Directives
#1
ng-model Directives

-Binds the html controls to application data
-supported by <input>,<select>,<Textarea> html controls
-Simple meaning that ng-model get the data from input box or select from list and assign it to application data.

Syntax:
Code:
<element ng-model="nameofmodel"></element>

In below Example 'name' is model and assigned to scope

Example:
Code:
<!DOCTYPE html>
<html ng-app="myApp" >
<head>
<title>mvc</title>
<script src="../angular.min.js"></script>
<script type="text/javascript">
var app=angular.module("myApp",[]);
app.controller("myController",function($scope){
$scope.name="ravi"; //here model name is 'name'
});
</script>
</head>
<body>
<div ng-controller="myController">
here we defined model from controller to input box<br>

<input ng-model="name">

<br>
{{name}}

</div>

</body>
</html>

OUTPUT:
[Image: KIKM3qS.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)