Create AngularJS ng-model Directive (#27791)
This commit is contained in:
29
guide/english/angularjs/angularjs-ng-model/index.md
Normal file
29
guide/english/angularjs/angularjs-ng-model/index.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
title: AngularJS ng-model Directive
|
||||||
|
---
|
||||||
|
# AngularJS ng-model Directive
|
||||||
|
------
|
||||||
|
With the ng-model directive you can bind the value of an input field to a variable created in AngularJS.
|
||||||
|
|
||||||
|
Example
|
||||||
|
```html
|
||||||
|
<div ng-app="myApp" ng-controller="myCtrl">
|
||||||
|
Name: <input ng-model="name">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var app = angular.module('myApp', []);
|
||||||
|
app.controller('myCtrl', function($scope) {
|
||||||
|
$scope.name = "John Doe";
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
Two-Way Binding example
|
||||||
|
```html
|
||||||
|
<div ng-app="myApp" ng-controller="myCtrl">
|
||||||
|
Name: <input ng-model="name">
|
||||||
|
<h1>You entered: {{name}}</h1>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
More info @ [https://www.w3schools.com/angular/angular_model.asp](https://www.w3schools.com/angular/angular_model.asp)
|
Reference in New Issue
Block a user