繁体   English   中英

在AngularJS表中使用过滤器

[英]using filter in AngularJS table

我正在mvc with angularjsmvc with angularjs创建一个Web应用程序,我想在其中过滤表中的数据,但是在调试代码时出现错误。

这就是错误所在

错误:$ rootScope:infdig无限$ digest循环10已完成$ digest()迭代。 中止! 观察者在最近5次迭代中被解雇:[]

我尝试过这样的事情

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

然后在thead添加了另一个tr

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

这是我的桌子的样子

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

我只想了解,我该如何为用户提供过滤器?

您需要更改以下行

<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')}">

而且一切都很好

暂无
暂无

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

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