2017-03-27 172 views
1

我在mvc with angularjs中創建了一個Web應用程序,其中我想過濾表格中的數據,但在調試代碼時出現錯誤。在AngularJS表中使用過濾器

這是錯誤is

Error: $rootScope:infdig Infinite $digest Loop 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: []

我想是這樣的

<tr ng-repeat="d in dataintbl| filter:search"> 

和我在thead

<td> 
    <input type="text" ng-model="search.taskstartdate" placeholder="" class="erp-input" /> 
</td> 

又增加了tr這是怎麼了我的表看起來

<table class="table table-bordered"> 
    <thead> 
    <tr class="bg-primary"> 
     <th>Task Name</th> 
     <th>Start Date</th> 
     <th>End Date</th> 
     <th>Priority</th> 
     <th>Action</th> 
     <th ng-hide="true">autoid</th> 
    </tr> 
    <tr> 
     <td> 
      <input type="text" ng-model="search.taskstartdate" placeholder="" class="erp-input"/> 
     </td> 
    </tr> 
    </thead> 
    <tbody> 
    <tr ng-repeat="d in dataintbl" ng-class="{'changecolor':(d.IsCompleted=='True')}"> 
     <td><a href="#" style="cursor:pointer;" ng-click="showdetails(d)" data-toggle="modal" data-target="#myModalc">{{d.taskname}}</a> 
     </td> 
     <td>{{d.taskstartdate}}</td> 
     <td>{{d.taskenddate}}</td> 
     <td ng-class="{'greenrow': (d.taskpriority == 'Low'), 'yellowrow': (d.taskpriority == 'Medium'), 'redrow': (d.taskpriority == 'High')}"> 
      {{d.taskpriority}} 
     </td> 
     <td> 
      <span ng-class="{'hidespan':(d.IsCompleted=='False')}">Completed</span> 
      <div ng-class="{'hidebutton':(d.IsCompleted=='True')}"> 

       <a href="#" ng-click="updatetask(d)" data-toggle="modal" title="EDIT TASK" data-target="#myModalb" 
        class="btn btn-warning glyphicon glyphicon-edit"></a> 
       <a href="#" ng-click="deleteuser(d)" title="DELETE TASK" 
        class="btn btn-danger glyphicon glyphicon-trash"></a> 
       <a href="#" ng-click="taskcompleted(d)" title="COMPLETE TASK" 
        class="btn btn-success glyphicon glyphicon-ok"></a> 
      </div> 
     </td> 
    </tr> 
    </tbody> 
</table> 

我只是想了解,我如何給用戶過濾器?

+4

你能提供你的代碼的小提琴/ plunker –

+0

創建小提琴或猛擊請 –

+0

你使用的是什麼?給一些示例數據..您的一些數據可能會導致問題 –

回答

1

需要

<tr ng-repeat="d in dataintbl" ng-class="{'changecolor':(d.IsCompleted=='True')}"> 

更改以下行來這樣的事情

<tr ng-repeat="d in dataintbl | filter:search.taskstartdate" ng-class="{'changecolor':(d.IsCompleted=='True')}"> 

,一切都看起來很好