In my search feature, I have a suggestion box that appears below the search field when I start typing. I want the suggestion box to disappear when I click outside the search field, and also be able to click on a suggestion to perform a search.
<input ng-blur="suggestionBox.hide()" ng-model='someModel' />
<div class='suggestion-box'>
<ul>
<li ng-repeat="suggestion in suggestions" ng-click="someFunction()">suggestion.name</li>
</ul>
</div>
The issue I am facing is that the ng-click
is not triggered when the ng-blur
hides the suggestion box. I have tried using
ng-click="$event.preventDefault(); someFunction()"
but it did not work. I also attempted to set a timeout on the hide()
method, which worked but required a long delay of 200ms, making it an inefficient solution.