olivier olivier - 1 year ago 91
Javascript Question

Hide a div with angular if the input field is empty

At the moment my code works if the view loads and there is no focus in the input field. The div is hidden with this code:

<i class="icon ion-search placeholder-icon"></i>
<input type="text" placeholder="Solothurn durchsuchen..." name="text" ng-model="searchBox.storeName">
<div ng-repeat="item in posts | filter:searchBox" class="card has-header" ng-show="searchBox">
<div class="w shop">{{item.storeName}}</div>
<p class="w">

But my goal is, that when the user deletes the text in the input field the divs are again hidden. How can I do this?
Any help much appreciated!

Answer Source

just use ng-show="searchBox.storeName.length > 0" and that'll server your purpose