vsGoogleAutocomplete
vsGoogleAutocomplete copied to clipboard
Impossible to empty the input text
Hi,
if you search for a city and then you get the result, when you try to empty the input text the last result will be set to the input (the model).
So:
- search for 'Rome'
- you get 'Rome, Italy'
- empty the input
- you get 'Rome, Italy' again when the input loses the focus
Hi @wideawake,
Currently behavior is you should click enter button to apply changes. I think it may cause issues on mobile devices.
is this issue solved ? i'm also facing same issue(empty the input)
Will be solved asap
i've had the same problem and fixed it forcing the clear of autocomplete model: the 'autocomplete' parameter is the input where autocomplete is located;
var input = angular.element(document.querySelectorAll('input[name=autocomplete_location]'));
clearAutoCompleteModel(getAutoCompleteObj(input[0]));
function getAutoCompleteObj(element) {
for (var key in element) {
if (key.indexOf('jQuery') == 0 && element[key].$vsGoogleAutocompleteController)
return element[key];
}
}
function clearAutoCompleteModel(autocomplete) {
let auto = autocomplete;
let modelCtrl = auto.$ngModelController;
let viewValue = modelCtrl.$viewValue == "" ? '' : modelCtrl.$viewValue;
if (!viewValue) $scope.jobPosition = new JobPosition();
$timeout(function () {
$scope.$apply(function () {
modelCtrl.$setViewValue(viewValue);
modelCtrl.$render();
});
});
};
this make me able to clean input after the selection of one place inside autocomplete. i think it's easy to fix it directly inside the code. Obviusly there'll be an issue with the required validation, that doesn't accept any empty value. Now i'm not able to give time to this issue, but i would like to make a PR.
What line should I put this in? because I'm getting a Cannot read property '$ngModelController' of undefined
in my console.
Was this problem ever fixed? It still persists today @vskosp