2015-03-08 56 views
0

所以我得到了一個應用了過濾器的ng-repeat,效果很好!但是當我加載這個時,表中沒有任何顯示。在應用過濾器之後,數據顯示以及何時刪除過濾器(即查詢),然後將所有數據顯示在表格中。Angular ng-repeat在應用過濾器之前顯示數據

所以我的問題是如何使表展又名內容中的所有數據,只有當我在寫輸入應用濾鏡....

謝謝!

<div class="container" ng-controller="AppCtrl"> 
     <h1>HearthDB</h1> 
     Class: <input ng-model="classQuery"> 
     Cost: <input ng-model="costQuery"> 
     </br> 
     Type "Spell/Minion": <input ng-model="typeQuery"> 
     Secret: <input ng-model="secretQuery"> 
     <table class="table table-bordered table-hover"> 
      <thead> 
       <tr> 
        <th>Name</th> 
        <th>Type</th> 
        <th>Cost</th> 
        <th>Text</th> 
        <th>Class</th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr ng-repeat="content in data | filter:{playerClass: classQuery, cost: costQuery, type: typeQuery, text: secretQuery}" ng-if="content.collectible && content.cost"> 
        <th>{{content.name}}</th> 
        <th>{{content.type}}</th> 
        <th>{{content.cost}}</th> 
        <th ng-bind-html="to_trusted(content.text)"></th> 
        <th>{{content.playerClass}}</th> 
       </tr> 
      </tbody> 
     </table> 

    </div> 
+0

頁面初始化時,過濾器變量是否在angular-batarang或ng-inspector中顯示一些值或似乎未初始化?只是一個預感,因爲它聽起來像一切正常,一旦一些交互發生... – orbitbot 2015-03-08 23:08:14

+0

我剛剛解決了這個問題我會把我的代碼,以幫助有這個問題的人! – 2015-03-08 23:37:20

回答

0

嘿傢伙這是我需要解決我的問題。希望這有助於

<div class="container" ng-controller="AppCtrl"> 
     <h1>HearthDB</h1> 
     Class: <input ng-model="classQuery.playerClass"> 
     Cost: <input ng-model="costQuery.cost"> 
     </br> 
     Type "Spell/Minion": <input ng-model="typeQuery.type"> 
     Secret: <input ng-model="secretQuery.text"> 
     <table class="table table-bordered table-hover"> 
      <thead> 
       <tr> 
        <th>Name</th> 
        <th>Attack</th> 
        <th>Health</th> 
        <th>Type</th> 
        <th>Cost</th> 
        <th>Text</th> 
        <th>Class</th> 
       </tr> 
      </thead> 
      <tbody> 
        <tr ng-repeat="content in data | filter: classQuery | filter: costQuery | filter: typeQuery | filter: secretQuery" ng-if="content.collectible && content.cost"> 

        <th>{{content.name}}</th> 
        <th>{{content.attack}}</th> 
        <th>{{content.health}}</th> 
        <th>{{content.type}}</th> 
        <th>{{content.cost}}</th> 
        <th ng-bind-html="to_trusted(content.text)"></th> 
        <th>{{content.playerClass}}</th> 
       </tr> 
      </tbody> 
     </table> 

    </div> 
相關問題