David Luque
David Luque

Reputation: 1108

How to detect blank input angular.js

I have a angular form with a few inputs. I need to know when the input is empty when I click a button to search without refresh the browser.

 <input ng-model="formData.city" type="text" id="city-selector" placeholder="Ciudad o localidad" onfocus="this.value = '';">

If I make a search with a city "City", the next time I search with the value "" I get "City" in the controller. How can I delete this value without delete the $scope.formData?

Thanks

Upvotes: 0

Views: 90

Answers (1)

QUIPHOP
QUIPHOP

Reputation: 93

Try to use ng-focus="formData.city = ''" rather than onfocus="this.value = '';"

Upvotes: 1

Related Questions