2016-07-28 57 views
0

我只想顯示其數據來自API的列表項目。我想用一種標準的方式,只顯示那些數據是從API使用ng-hide在角度數據的基礎上隱藏列表項目

[ 
    { 
    "_id": "57998a58d5692e2b00e5de9f", 
    "query_string": "snowy", 
    "query_type": "others", 
    "timestamp": "2016-07-28T04:30:16.624Z", 
    "__v": 0, 
    "social_media": [ 
     6, 
     1 
    ] 
    }, 
    { 
    "_id": "5799aedad5692e2b00e5df37", 
    "query_string": "Edhi", 
    "query_type": "others", 
    "timestamp": "2016-07-28T07:06:02.113Z", 
    "__v": 0, 
    "social_media": [ 
     1, 
     6, 
     2, 
     4, 
     3 
    ] 
    },] 

未來

<div class="row" ng-repeat="query in prev_queries"> 
         <div class="col-md-12 cell"> 
         <div class="well" > 
          <p class="history">{{query.query_string}}</p> 
          <ul class="history-filter"> 
           <li ng-hide="true"> <i class="fa fa-twitter fa-2x" aria-hidden="true"></i> </li> 
           <li ng-hide="true"> <i class="fa fa-facebook fa-2x" aria-hidden="true"></i> </li> 
           <li ng-hide="false"> <i class="fa fa-instagram fa-2x" aria-hidden="true"></i> </li> 
           <li ng-hide="true"> <i class="fa fa-youtube fa-2x" aria-hidden="true"></i> </li> 
           <li ng-hide="false"> <i class="fa fa-flickr fa-2x" aria-hidden="true"></i> </li> 
          </ul> 
          <p class="history-time"> {{query.timestamp | date}}</p> 
          <span class="pull-right"> <span class="bigcheck"> 
          <label class="bigcheck"> 
          <input type="checkbox" class="bigcheck" onchange="showHideIndividualAttributes(this); return false" value="1" /> 
          <span class="bigcheck-target"></span> </label> 
          </span> </span> 
         </div> 
         </div> 
</div> 

數據在上述情況下只顯示其數據存在social_media數組列表項。有沒有這種使用NG-重複

回答

1

你不需要使用NG隱藏了這個問題,如果你有固定病症使用的NG-如果爲了這個目的

<div class="row" ng-repeat="query in prev_queries"> 
         <div class="col-md-12 cell"> 
         <div class="well" > 
          <p class="history">{{query.query_string}}</p> 
          <ul class="history-filter"> 
           <li ng-repeat-start="media in query.social_media" ng-if"media == 1"> <i class="fa fa-twitter fa-2x" aria-hidden="true"></i> </li> 
           <li ng-if="media == 2"> <i class="fa fa-facebook fa-2x" aria-hidden="true"></i> </li> 
           <li ng-if="media == 3"> <i class="fa fa-instagram fa-2x" aria-hidden="true"></i> </li> 
           <li ng-if="media == 4"> <i class="fa fa-youtube fa-2x" aria-hidden="true"></i> </li> 
           <li ng-if="media == 5" ng-repeat-end> <i class="fa fa-flickr fa-2x" aria-hidden="true"></i> </li> 
          </ul> 
          <p class="history-time"> {{query.timestamp | date}}</p> 
          <span class="pull-right"> <span class="bigcheck"> 
          <label class="bigcheck"> 
          <input type="checkbox" class="bigcheck" onchange="showHideIndividualAttributes(this); return false" value="1" /> 
          <span class="bigcheck-target"></span> </label> 
          </span> </span> 
         </div> 
         </div> 
</div> 
+0

@usama是露出太多的清單項目,而隱藏它們。我猜ng-repeat-start不在正確的位置 – user2885910

+1

nope它的工作正常我正在糾正我的語法錯誤這是equall符號我在ng中失蹤 - 如果 –

+0

喲它的工作非常感謝 – user2885910

0

你可以嘗試處理NG-顯示

<div class="row" ng-repeat="query in prev_queries" ng-show="query.social_media.length > 0"> 

有了這一個,在社交媒體數組爲空,則不會顯示任何方法。

相關問題