Last active
March 27, 2017 17:11
-
-
Save itswadesh/12c9a1c7a6e89c15591a5fef8c9823bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('myApp',[]); | |
app.controller('votingCtrl', function($scope, $http) { | |
$http.post('ajax/getPosts.php').success(function(data){ | |
$scope.posts = data; | |
}); | |
$scope.upVote = function(post){ | |
post.votes++; | |
updateVote(post.id,post.votes); | |
}; | |
$scope.downVote = function(post){ | |
post.votes--; | |
updateVote(post.id,post.votes); | |
}; | |
function updateVote(id,votes){ | |
$http.post('ajax/updateVote.php?id='+id+'&votes='+votes); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment