2016-03-01 2 views
0
$scope.addMedication = function(med) { 
    $http.post('/medications', { 
     name: med.name, 
     slug: med.slug, 
     description: med.description 
    }).success(function(medication) { 
     $scope.newMedicationTitle = ''; 
     $scope.medications.push(medication); 
    }).error(function(err) { 
     // Alert if there's an error 
     return alert(err.message || "an error occurred"); 
    }); 
    }; 

Этот код. Я хочу опубликовать весь объект без использования отдельных полей. Как я могу это сделать?Угловой почтовый метод с развернутым

ответ

0

Как что:

$scope.addMedication = function(med) { 
    $http.post('/medications', med).success(function(medication) { 
     $scope.newMedicationTitle = ''; 
     $scope.medications.push(medication); 
    }).error(function(err) { 
     // Alert if there's an error 
     return alert(err.message || "an error occurred"); 
    }); 
    }; 
Смежные вопросы