Change a Model Value by Controller Function
Description
The following code shows how to change a Model Value by Controller Function.
Example
<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
<script>
function MyCtrl($scope) {<!--from w ww. j av a 2 s. c om-->
$scope.value = 1;
$scope.incrementValue = function(value) {
$scope.value += 1;
};
}
</script>
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body ng-app>
<div ng-controller="MyCtrl">
<p ng-init="incrementValue(5)">{{value}}</p>
</div>
</body>
</html>