Angular JS使用"多个过滤器"

时间:2014-04-13 15:37:35

标签: angularjs angularjs-ng-repeat

我在SharePoint 2013应用程序中使用AngularJS,但我认为这里的SharePoint不会影响响应(不过我可能会错在那里)。

我有一个大约350个请求的自定义列表,每个请求都包含一个(开发,设计,EmailCampaign,AdWords)列表中的RequestType和一个标题(任何其他信息都无关紧要)。

在应用程序的登陆页面上,我提供了4个表(每个RequestType一个),以便负责人更容易看到他们的队列。我还在每个表中添加一个文本输入,按标题过滤结果,以便用户快速找到任务。

我可以让任何一个过滤器独立于另一个工作,但我不知道如何一起实现它们。可以这样做吗?如果是这样,怎么样?

示例数据:

{ title: Easter Sale Campaign, RequestType: EmailCampaign},
{ title: Easter Sale Microsite Prototype, RequestType: Design},
{ title: Easter Sale Microsite Sprites, RequestType: Design},
{ title: Easter Sale AdWords Analytics, RequestType: AdWords},
{ title: Easter Sale Microsite Build, RequestType: Development},
{ title: Easter Sale Microsite Test, RequestType: Development},
{ title: Easter Sale PromoteToProduction, RequestType: Development},
{ title: Spring Sale Campaign, RequestType: EmailCampaign},
{ title: Spring Sale Microsite Prototype, RequestType: Design},
{ title: Spring Sale Microsite Sprites, RequestType: Design},
{ title: Spring Sale AdWords Analytics, RequestType: AdWords},
{ title: Spring Sale Microsite Build, RequestType: Development},
{ title: Spring Sale Microsite Test, RequestType: Development},
{ title: Spring Sale PromoteToProduction, RequestType: Development}

HTML

<div id="landing_header_bar" data-tbl="tblDesign" class="clr-blue">
    <img alt="Close This" class="btnToggleLanding" src="../Images/close_btn.png" ng-click="taskClose = true" ng-hide="taskClose" />
    <img alt="Open This" class="btnToggleLanding" src="../Images/open_btn.png" ng-click="taskClose = false" ng-show="taskClose" />
    <h3 class="divider_title inlined">Design Requests</h3>
    <span class="filterQueue">
        Filter:&nbsp;<input type="text" ng-model="taskFilter" />
    </span>
</div>
<table class="tblLanding">
    <tr class="landing_header_row">
        <th ng-click="doTasksSort('Priority')">Priority</th>
        <th ng-click="doTasksSort('Task_Id')">ID</th>
        <th ng-click="doTasksSort('Description')">Title</th>
        <th ng-click="doTasksSort('RequestType')">Task Type</th>
    </tr>
    <tbody>
        <tr class="landing_data_row" ng-repeat="req in requests | filter:request.requestType="Design" | orderBy:sortTasksBy:!reverse">
            <td style="text-align:center;">
                <img ng-src="../Images/{{req.Priority}}.jpg" />
            </td>
            <td style="text-align:center;">{{req.Task_Id}}</td>
            <td><a href="#">{{req.title}}</a></td>
            <td>{{req.requestType'}}</td>
        </tr>
        <tr ng-show="requests.length == 0"><td colspan="8" align="center"><strong>No Requests Found!</strong></td></tr>
    </tbody>
</table>

1 个答案:

答案 0 :(得分:2)

您在“设计”周围使用双引号打破了过滤器链。

您应该像这样使用它:

<tr class="landing_data_row" ng-repeat="req in requests | filter:request.requestType='Design' | orderBy:sortTasksBy:!reverse">

<tr class="landing_data_row" ng-repeat='req in requests | filter:request.requestType="Design" | orderBy:sortTasksBy:!reverse'>