我试图从下拉列表中选择与angularjs的值。当我选择的价值我得到这个错误angular.min.js:108 TypeError: Cannot read property 'ftype' of undefined
从angulars下拉列表中获取选择值读取错误
HTML
<select name="select" ng-model="queryBy" ng-change="get_search_value(item)">
<option ng-repeat="item in filter" value="{{item.ftype}}">{{item.ftype}}</option>
</select>
JS
$scope.search_type='';
$scope.filter = [
{ id: 1, ftype: "Complaint Type"},
{ id: 2, ftype: "Region" },
{ id: 3, ftype: "District"},
];
$scope.get_search_value=function(item){
$scope.search_type=item.ftype;
alert(item.ftype)
}
但功能在哪里 – user6579134
这是不需要的,AngularJS会自动更新'$ scope.queryBy'以匹配选定的选项的值。如果您需要在变更时做其他事情,则可以将其添加回来,但不需要更新搜索类型。 –