简体   繁体   English

在AngularJS表中使用过滤器

[英]using filter in AngularJS table

I'm creating a web app in mvc with angularjs in which i want to filter the data inside my table but I'm getting error while I debug my code. 我正在mvc with angularjsmvc with angularjs创建一个Web应用程序,我想在其中过滤表中的数据,但是在调试代码时出现错误。

This is what the error is 这就是错误所在

Error: $rootScope:infdig Infinite $digest Loop 10 $digest() iterations reached. 错误:$ rootScope:infdig无限$ digest循环10已完成$ digest()迭代。 Aborting! 中止! Watchers fired in the last 5 iterations: [] 观察者在最近5次迭代中被解雇:[]

I tried something like this 我尝试过这样的事情

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

and I added another tr in my thead 然后在thead添加了另一个tr

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

this is how my table looks 这是我的桌子的样子

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

I just want to understand, how can i give filters to the users? 我只想了解,我该如何为用户提供过滤器?

you need to change the following line 您需要更改以下行

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

to something like this 像这样

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

and everything is looking fine 而且一切都很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM