ng-click counter

Description

The following code shows how to create a counter based on ng-click.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from   w  w  w . j  ava2  s  . co m-->
<body>
  <div ng-app="">
  <div ng-click="count = count + 1" ng-init="count=0">
    Click to Increment
      <div ng-click="count = count - 1; $event.stopPropagation();">Click to Decrement</div>
  </div>
  count: {{count}}
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities