AngularJS ng-model Directive – AngularJS


# 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

<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

<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

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.