angularjs - Send Angular model to backend -
i have various inputs call function when changed:
$scope.updateoutputdata = function(){ // gathering data , 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 send object read backend }
basically function gathers input data , afterward should send object backend, in backend can process data , depending on it, return json api data database.
i not know how code this. added comment in bottom of method. there should code sends data backend , expects json api returned. how code like?
you should in angular
$http.post(url, data).success(onsuccess).error(onerror); function onsuccess() { //your success logic; } function onerror() { // error logic }
in server - supposing using java should like:
@requestmapping(method = requestmethod.post, value = "/yoururl", headers = "accept=application/json, text/html") public modelandview updateactivities (@requestbody yourdatamodel data) { //your server logic }
Comments
Post a Comment