deployd的角柱法

时间:2016-03-01 20:26:42

标签: angularjs post web deployd dpd

$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");
    });
  };

拥有此代码。我想发布整个对象而不使用单独的字段。我怎么能这样做?

1 个答案:

答案 0 :(得分: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");
    });
  };