我有一个ui-bootstrap type-ahead,可以从JSON doc中提取状态。有用。我需要的是获取所选值并在另一个对象中使用它来根据该选择检索数据。当我使用提前输入函数调用输入字段的$ scope值时,值是否通过?我猜,但是当我用它作为下拉选择时它会起作用。我在这里缺少什么?
状态提前:
<input type=text ng-model="selectedState"typeahead="state.value for state in states | fileter: $viewValue | limitTo:3" ng-change="updateState()" placeholder="Enter State"/>
或 状态下拉选择:
<select ng-options="state.value for state in states" ng-model="selectedState" ng-change="updateState()"></select>
控制器:
$scope.updateState = function(){
$scope.wCenters = wCenterFactory.get({state:$scope.selectedState.value});
};
答案 0 :(得分:1)
也许尝试选择typeahead-on-select而不是ng-change?我认为它会传递所选项目。