Increase value in scope for each click

Description

The following code shows how to Increase value in scope for each click.

Example


<!--  w w  w  . j  a  v a 2 s  .c  o  m-->
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head>
<body ng-app="myApp">
  <div ng-controller="MyCtrl">
    <a ng-click="inactive = !inactive">toggle active</a>
    inactive={{inactive}}
    <br><input type="text" ng-disabled="inactive" ng-model="input1">
    <br><a ng-click="inactive || (prop1=prop1 + 1)">click to increase</a> {{prop1}}
</div>
<script type='text/javascript'>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
    $scope.inactive= false;
    $scope.prop1 = 1;
}
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities