2016-04-19 12 views
0

ビューがロードされ、入力フィールドにフォーカスがない場合、私のコードは機能します。 div要素は、このコードで隠されている:入力フィールドが空白の場合、角を含むdivを非表示にする

<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"> 

しかし、私の目標は、ユーザーが入力フィールドにテキストを削除するときのdivが再び隠されていること、です。これどうやってするの? ご迷惑をおかけして申し訳ありません。

+1

'NG-紹介' – Tushar

+0

' ng-show'は 'searchBox.storeNを使っていますame.length'? – Rayon

+1

@olivier、Tusharはより正確です:) – Rayon

答えて

1

がちょうど ng-show="searchBox.storeName.length > 0"を使用しようとすると、それは、サーバあなたの目的= "searchBox.storeName"

+0

うん、これはあなたに感謝しました – olivier

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"> 
0

この

<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"> 
関連する問題