Read binded value from controller

Description

The following code shows how to Read binded value from controller.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
<!--from  w  w w  . j  ava  2  s  . c om-->
var app = angular.module("app", []);

app.controller("FormCtrl", ["$scope", function FormCtrl($scope) {
  $scope.submit = function() {
      $scope.submitValue = $scope.test;
  };
}]);
</script>
</head>
<body ng-app="app">
  <div ng-controller="FormCtrl">
    <input type="text" name="test" ng-model="test" />
    <button type="button" ng-click="submit()">Submit</button>
    Last submitted value: {{ submitValue }}
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities