【发布时间】:2013-09-20 20:27:54
【问题描述】:
我正在使用Angular Bootstrap UI typeahead 并尝试更新预输入中的模型值。但更新后的模型值不会反映更改,除非特别应用。
<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 代码: http://plnkr.co/edit/pNxBMgeKYulLuk7DO0gB?p=preview
【问题讨论】:
标签: angularjs angular-ui angular-ui-bootstrap