ng-model links to scope

Description

The following code shows how to link ng-model to scope.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
function HelloCtrl($scope) {<!-- w  ww . jav  a  2  s .com-->
    $scope.name = 'Bob';
}
</script>
</head>
<body ng-app>
    <div ng-controller="HelloCtrl">
        <p>Hello, {{name}}</p>
        <p>Your name: <input ng-model="name" /></p>
    </div>
  
</body>

</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities