【问题标题】:angular post method with deployd已部署的角柱方法
【发布时间】:2016-03-01 20:26:42
【问题描述】:
$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");
    });
  };

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

【问题讨论】:

    标签: angularjs post web deployd dpd


    【解决方案1】:

    像这样:

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

    【讨论】:

      猜你喜欢
      • 2018-03-20
      • 2021-06-12
      • 2018-09-18
      • 2017-04-11
      • 2018-06-21
      • 2019-02-12
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      相关资源
      最近更新 更多