angular ui bootstrap 提前输入 - 在 select 回调之前

angular ui bootstrap typeahead - Before select callback

在更改模型之前是否可以获取 angular ui bootstrap 预输入选择的值?

非常感谢!

乌里

没有使用 typeahead 执行此操作的内置方法,但您可以将旧值存储在 ng-change 中

<input type="text" ng-model="foo" typeahead="bar in bars" ng-change="storeLast()">
$scope.storeLast() = function(){
    //Before you reassign oldFoo, you can do some work with it here.
    oldFoo=foo
}

然而,这感觉像是一件很奇怪的事情。我认为更好的答案是重新设计您正在尝试做的事情,这样您就不需要奇怪的代码来完成它。