下拉
HTML
<select data-ng-model='datasource.value' ng-options='sourcetype.dataSourceType as sourcetype.dataSourceDesc for sourcetype in sourcetypes' data-ng-change="getAccountCredentials(sourcetype);">
<option disabled value="" selected>Choose One</option>
</select>
的JavaScript
$scope.getAccountCredentials = function(data){
console.log(data);
}
我无法获得选定的值。
请建议使用角度方式
答案 0 :(得分:1)
您已使用datasource.value
data-ng-model='datasource.value'
尝试删除data-ng-change="getAccountCredentials(sourcetype);"
:
<select data-ng-model='datasource.value' ng-options='sourcetype.dataSourceType as sourcetype.dataSourceDesc for sourcetype in sourcetypes'>
<option disabled value="" selected>Choose One</option>
</select>
只需使用$ watch即可观看datasource.value
$scope.$watch("datasource.value",function(newValue){
console.log(newValue);
});