Anuj Gupta Anuj Gupta - 1 year ago 102
AngularJS Question

Dynamic Update value on click counter Angular Js

I created a Post page where i want to update value on click on like or dislike .I created a fiddle for this

Fiddle:- [][1]

.When i click on like then Like counter will increase and when i click on dislike then dislike counter will increase.

Answer Source

You need to have two function to add and remove,


 <div class="post" ng-repeat="post in posts">
      <a href="#" ng-click="add(post)">like</a> ({{}})
      <a href="#" ng-click="remove(post)">Dislike</a> ({{post.dislike}})


 $scope.add = function(post) { +=1;

  $scope.remove = function(post) {
    post.dislike +=1;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download