2017-05-04 88 views
0

我有一個下拉列表 -Angularjs - 的選擇獲取所選項目的文本不NG選項

<select ng-model="contact.type" id="select_{{$index}}" ng-change="changedValue()" class="searchCriteria"> 
        <option>Policy Number</option> 
        <option>Insured Name</option> 
       </select> 

我想用angularjs獲得所選擇的項目。到目前爲止,我已經嘗試過

$scope.changedValue = function() { 
    alert($(".searchCriteria option:selected").html()); 
} 

等等。但每次警報顯示「未定義」。我如何獲取選定的選項文本?

回答

1

您可以只使用$範圍變量,

$scope.changedValue = function() { 
    alert($scope.contact.type); 
}