获取选定的选项并在 Angularjs 中使用 $http 传递它?

Get selected options and pass it using $http in Angularjs?

我正在尝试传递选定的选项值,调用更改时的函数。

<div class="col-md-4">

  <select id="mkSelect" ng-model="formData.mk" name="mkSelect" ng-options="mk.MkIdLabel group by mk.FY for mk in mks" ng-change="update()" class="form-control">
  </select>
</div>

在控制器中:

$scope.update = function() {

  // this displays the MarketId value in the log
  console.log($scope.formData.mk.MarketId);

  $http({
      method: 'POST',
      url: 'getMailStatus.php',
      // but while trying to send to "getMailStatus.php" it says its undefined 
      data: $.param($scope.formData.mk.MarketId),
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    })
    .success(function(data) {
      console.log(data);


      if (!data.success) {
        // if not successful, bind errors to error variables

      } else {
        // if successful, bind success message to message
        $scope.message = data.message;
      }
    });

};

console.log 显示选定的 id ,但是当我尝试使用 $http 传递相同的 id 时,它显示未定义 ($scope.formData.market.MarketID = undefined)

谁能指出我做错了什么?

$.param 需要一个对象,而不是一个简单的值。 http://api.jquery.com/jquery.param/

试试这个:

data: $.param({mkId: $scope.formData.mk.MarketId}),