I am using the Angular Bootstrap UI typeahead and trying to update the model value inside the typeahead. But the updated model value does not reflect the changes unless specifically applied.
<input ng-model="query" typeahead="option for option in getOptions($viewValue)">
app.controller('MainCtrl', function($scope) {
$scope.query = '';
$scope.getOptions = function(query){
if(query == "foo"){
$scope.query = "foobar";
// uncommenting the next line works but also raises error
// $scope.$apply()
return []
}
return ["I have an idea", "I have new idea"];
}
});
Plunker Code: http://plnkr.co/edit/pNxBMgeKYulLuk7DO0gB?p=preview