Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.