Angularjs angular ui引导类型预选-选择回调之前

Angularjs angular ui引导类型预选-选择回调之前,angularjs,twitter-bootstrap,angular-ui,typeahead,Angularjs,Twitter Bootstrap,Angular Ui,Typeahead,在angular ui bootstrap typeahead选择更改模型之前,是否需要获取该选择的值 非常感谢 Uri使用typeahead没有内置的方法,但是您可以将旧值存储在您的ng更改中 <input type="text" ng-model="foo" typeahead="bar in bars" ng-change="storeLast()"> $scope.storeLast() = function(){ //Before you reassign oldF

在angular ui bootstrap typeahead选择更改模型之前,是否需要获取该选择的值

非常感谢


Uri

使用typeahead没有内置的方法,但是您可以将旧值存储在您的ng更改中

<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
}

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

为什么?这听起来很像XY问题。而且,答案几乎肯定是否定的。谢谢。我确信typeahead选择会触发ng更改。这看起来是个好主意solution@UriKlar这是一个不错的解决方案,但我真的认为你有一个更大的潜在问题。