我正在使用Bootstrap-UI的鍵入指令,並且我想清除select上的模型,從而清除鍵入字段(值將存儲在別處)。在Bootstrap-UI的鍵入清除模型
我只是似乎無法得到typeahead更新後,我已經清除模型。
我創建了顯示錯誤plnkr:http://plnkr.co/edit/NitVqHyfE3pfSUIhjUZ3?p=preview
我正在使用Bootstrap-UI的鍵入指令,並且我想清除select上的模型,從而清除鍵入字段(值將存儲在別處)。在Bootstrap-UI的鍵入清除模型
我只是似乎無法得到typeahead更新後,我已經清除模型。
我創建了顯示錯誤plnkr:http://plnkr.co/edit/NitVqHyfE3pfSUIhjUZ3?p=preview
您使用不正確的型號名稱。您使用的模型被稱爲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)
}
我可以找到最好的解決辦法是
$('.typeahead').typeahead('val', myVal);
您可以通過這種方法$( '預輸入 ')。預輸入(' VAL' 設置爲空字符串 「」 );
這將清空列表。