Angularjs Ng-model Instruction
Angularjs instance
The value of the bound input box to the scope variable:
<! DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<script src = "http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"> </ script>
</ head>
<body>
<div ng-app = "myApp" ng-controller = "myCtrl">
<input ng-model = "name">
<p> The value of the input box is bound to the variable "name": </ p>
{{name}}
</ div>
<script>
var app = angular.module ('myApp', []);
app.controller ('myCtrl', function ($ scope) {
$ scope.name = "John Doe";
});
</ script>
<p> This example demonstrates how to use the ng-model directive to bind the value of the input box to the scope variable. </ p>
</ body>
</ html> <="" pead>="" <body>="" <div="" ng-app="myApp" ng-controller="Myctrl" <input="" ng-model="name" <p>input="" the="" value="" of="" input="" box="" is="" bound="" to="" variable="" "name":<="" p>="" {{name}}="" <="" div>="" <script>="" var="" app="Angular.module" ('="" myapp="" ',="" []);="" app.controller="" myctrl="" function="" ($scope)="" {="" $scope.="" name="John Doe" ;="" });="" <p>="" this="" example="" demonstrates="" how="" use="" instruction="" binding="" into="" a="" scope="" variable.="" body>="" ptml>="" pre="">
Definitions and usage
The ng-model directive binds an HTML form element into a scope variable.
If a variable does not exist in scope, it will be created.
Grammar
<element ng-model= "Name" ></element>
<input>, <select>, <textarea>, the element supports the directive.
Parameter values
| value |
Description |
| Separator |
You want to bind to the form field's property name. |
The above is the Angularjs Ng-model data collation, follow-up continue to supplement the relevant information.