Javascript 使用标记选项拉出数据

Javascript 使用标记选项拉出数据,javascript,angularjs,Javascript,Angularjs,该块显示数据库中的值。选择该值后,我要拉出id 参考 {{ref.refere}} - //тут я бы хотел 点击 //选择 //контроллер и 控制器 selectInfo.controller('selectRefer', ['$scope', '$http', function ( $scope, $http) { $http({ method: 'get', url: 'mysite', }).then(func

该块显示数据库中的值。选择该值后,我要拉出id


参考
{{ref.refere}}
-  //тут я бы хотел 
点击
//选择
//контроллер и 
控制器

selectInfo.controller('selectRefer', ['$scope', '$http',
  function ( $scope, $http) {
    $http({
      method: 'get',
      url: 'mysite',
    }).then(function successCallback(response) {
      // Store response data
      $scope.refer = response.data;
      $scope.id = response.id
    });
}]);

如何通过单击按钮从选项标签中取出id-我不明白一些事情。

您应该使用ng选项,而不是ng重复

<select ng-controller="selectRefer"
        ng-options="ref.id as ref.name for ref in refer track by ref.id"
        ng-model="selectedRef">
    <option value="">Select</option>
</select>
<button ng-click="MyFunction(selectedRef)"> - </button> 


$scope.MyFunction= function(selectedRef){
    console.log(selectedRef);
}

选择
-  
$scope.MyFunction=function(selectedRef){
console.log(selectedRef);
}
使用将选择绑定到控制器。有关详细信息,请参阅。