My template can be found here http://goo.gl/xEttgl. I am hardcoding postData by declaring it as a global variable as
var postData = {'result': '27'};
app.factory('mypostService', function($http) {
return {
postFooOldSchool: function() {
$http.post('/angularresult', JSON.stringify(postData)
).success(function(data, status, headers){
}).error(function(data, status, headers){
});
}
}
});
app.controller('StartUpController', function($scope, $http, myService, mypostService) {
$scope.upvotes = 0;
$scope.serverupvotes = 0;
$scope.increase = function(){
$scope.upvotes = $scope.upvotes + 1;
};
mypostService.postFooOldSchool(function(data) {
});
myService.getFooOldSchool(function(data) {
$scope.result = data;
});
});
but what i would like to do is send postData dynamically from $scope inside StartUpController i.e lets say i click upvote button and i want to send the current value of $scope.upvotes in POST and display it in the result.