0

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">
    </label>
    <br><br>
    <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!

4
  • 1
    ng-show="searchBox.storeName" Commented Apr 19, 2016 at 11:31
  • ng-show directive using searchBox.storeName.length ? Commented Apr 19, 2016 at 11:31
  • 1
    @olivier, Tushar is more accurate :) Commented Apr 19, 2016 at 11:33
  • 1
    @olivier And Rayon is more readable :) Commented Apr 19, 2016 at 11:35

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

try this

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

Comments

0
<div ng-repeat="item in posts | filter:searchBox" class="card has-header" ng-if="searchBox.storeName != null">

OR

<div ng-repeat="item in posts | filter:searchBox" class="card has-header" ng-if="searchBox.storeName">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.