我正在使用Bootstrap-UI的typeahead指令,我想在select上清除模型,从而清除typeahead字段(值将存储在别处)。
在我清除模型之后,我似乎无法获得预先更新。
我创建了一个显示错误的plnkr:http://plnkr.co/edit/NitVqHyfE3pfSUIhjUZ3?p=preview
答案 0 :(得分:1)
您使用了错误的型号名称。您使用的模型称为selected
而不是selectedBrandInput
。
$scope.onBrandSelect = function ($item, $model, $label) {
$scope.state = $item; //save it somewhere
$scope.selected = undefined; //instead of $scope.selectedBrandInput = null;
if (!$scope.$$phase) {
$scope.$apply();
}
console.log($item)
}
答案 1 :(得分:-1)
我能找到的最佳解决方案是
$('.typeahead').typeahead('val', myVal);
您可以通过此方法设置空字符串$('。typeahead')。typeahead('val',“”);
这将清空列表。