将Angular模型发送到后端

I have various inputs that call this function when they are changed:

$scope.updateOutputData = function(){
    // gathering data and making data object
    $scope.selectionObject = {
      "departure_city" : departureCityDigest,
      "departure_country" : departureCountryDigest,
      "budget_min" : $scope.budget.min,
      "budget_max" : $scope.budget.max,
      "person_count" : $scope.selectedPersonCount,
      "currency" : $scope.selectedCurrency,
      "month" : $scope.selectedMonth,
      "year" : $scope.selectedYear,
      "flight_duration_min" : $scope.flightDuration.min,
      "flight_duration_max" : $scope.flightDuration.max
    };

    // implement functionality to send this object to be read by backend

}

Basically this function gathers all input data and afterward it should send that object to backend, so in backend I can process this data and then depending on it, return back JSON API with data from database.

I do not know how to code this. I added comment in the bottom of my method. There should be code that sends data to backend and expects some JSON API to be returned. How would that code look like?

$http.post(ENDPOINT, $scope.selectionObject).then(function(success) { /* awesome */ }, function(error) { /* error */ });

Sorry typed this using my iPhone. Don't forget to inject $http in your controller. And substitute ENDPOINT by your API URL.

You should do something like this in angular

        $http.post(url, data).success(onSuccess).error(onError);

         function onSuccess() {
                    //Your success logic;
                }

                function onError() {
                     // Your error logic
                }

In the server - supposing you are using java you should do something like:

 @RequestMapping(method = RequestMethod.POST, value = "/yourUrl", headers = "Accept=application/json, text/html")
    public ModelAndView updateActivities (@RequestBody YourDataModel data) {

           //your server logic
}