Reagan Stewart
Reagan Stewart

Reputation: 57

UI Bootstrap typeahead value to be used by other typeahead objects

I have a ui-bootstrap type-ahead that pulls the states from a JSON doc. It works. What I need is to take that selected value and use it in another objects to retrieve data based on that selection. When I call the $scope value of the input field with the type-ahead function the value isn't being pass? I guess,but when I use it as a drop-down select it works. What am I missing here?

State Type-ahead:

<input type=text ng-model="selectedState"typeahead="state.value for state in states | fileter: $viewValue | limitTo:3" ng-change="updateState()" placeholder="Enter State"/>

or State Drop-down select:

<select ng-options="state.value for state in states" ng-model="selectedState" ng-change="updateState()"></select>

controller:

$scope.updateState = function(){
  $scope.wCenters = wCenterFactory.get({state:$scope.selectedState.value});
};

Upvotes: 0

Views: 83

Answers (1)

Scott
Scott

Reputation: 1690

Maybe try typeahead-on-select instead of ng-change? I think that passes the selected item in.

Upvotes: 1

Related Questions