2016-08-02 55 views
1

我有3個按鈕組,刷新按鈕和表。 ALL |多佛|奧蘭多刷新數據僅在過濾條件

在頁面加載時,通過調用api將所有數據顯示在表中。

使用angularjs過濾器我已經過濾了基於城市的數據,即Dover或Orlando。

當前場景: 當用戶在Dover上並點擊刷新按鈕時,所有的數據被再次加載,即ALL和Refresh具有相同的API調用。

所需方案: 當用戶在Dover上並單擊刷新按鈕時,Dover數據應刷新。

代碼:

  <div class="myrow"> 
       <div class="col-md-6 col-sm-6"> 
        <label for="documentStatus">Queues: </label>      
        <div class="btn-group" role="group" aria-label="..."> 
         <button type="button" class="btn btn-primary active" ng-click="updateData(); myFilter = null">ALL</button> 
         <button type="button" class="btn btn-primary" ng-click="myFilter = {city : 'Dover'}">Dover</button> 
         <button type="button" class="btn btn-primary" ng-click="myFilter = {city : 'Orlando'}">Orlando</button> 
        </div> 
       </div> 
      </div> 

      <div class="container" ng-init="updateData()"> 
       <div class="pull-right"> 
        <button type="button" class="btn btn-primary btn-md" value="Refresh" ng-click="myFilter = null; updateData()"> 
         <span class="glyphicon glyphicon-refresh"></span> Refresh 
        </button> 
       </div> 
       <table class="table table-bordered"> 
        <thead> 
         <tr> 
          <th></th> 
          <th>Queue</th> 
          <th>No of Documents</th> 
          <th>Oldest document Datetime</th> 
          <th>Allocated Users</th> 
         </tr> 
        </thead> 
        <tbody ng-repeat="queue in Queues | filter: myFilter"> 
         <tr> 
          <td> 
           <label class="checkbox-table"> 
            <input type="checkbox" name="checkbox" ng-model="queue.isChecked" id="check-box-{{$index}}"> 
           </label> 
          </td> 
          <td class="col-md-3">{{ queue.queue }}</td> 
          <td class="col-md-2">{{ queue.noOfDocuments }}</td> 
          <td class="col-md-2">{{ queue.oldestDoc}}</td> 
          <td class="col-md-5">{{ queue.allocatedUsers}}</td> 
         </tr> 
        </tbody> 
       </table> 
      </div> 
+0

這聽起來更像是一個後端的問題給我,如果你只是想獲取由過濾資源城市'奧蘭多'。 如果您使用的是angulars'http http',您可以引入'parameters'屬性,該屬性將轉換爲ajax調用中的'GET'參數。 –

+0

爲以上代碼添加代碼.. –

+0

你的'update function'在哪裏? – developer033

回答

0

您可以嘗試使用angular.copy(ARR):

var data = { 
     original: myOriginalData, 
     filteredData: angular.copy(myOriginalData) //this is unbind link on the arrayy 
    };