无法使用搜索过滤器

时间:2016-06-07 18:56:48

标签: javascript angularjs angular-directive

无法使用filter: search显示结果。当我删除过滤器时,数据显示正确。

    <div class="col-md-12" ng-controller="workOrderController">
    <div class="row m-t-20 user_work_area_dashboard">
        <div class="col-md-3  text-center" >
            <ul class="tabs_left_dashboard">
                <li><a ng-click="search.status = ''" href="">ALL PROJECTS</a></li>
                <li><a ng-click="search.status = 'PORTFOLIO'" href="">PORTFOLIO</a></li>
                <li><a ng-click="search.status = 'CATEGORY'" href="">NOTIFICATIONS</a></li>
                <li><a ng-click="search.status = 'IN PROGRESS'" href="">RUNNING PROJECTS</a></li>
                <li><a ng-click="search.status = 'COMPLETED PROJECTS'" href="">COMPLETED PROJECTS</a></li>
                <li ng-if="$parent.role == 'admin'" href=""><a ng-click="search.status = 'OPEN'">OPEN PROJECTS</a></li>
                <li ng-if="$parent.role == 'admin'" href=""><a ng-click="search.status = 'ASSETS'">ASSETS</a></li>
                <li ng-if="$parent.role == 'admin'" href=""><a ng-click="search.status = 'JOB REQUESTS'">JOB REQUESTS</a></li>
            </ul>
        </div><!--end of tab buttons-->

        <div class="col-md-9">
            <div  cg-busy="{promise: myPromise}">
                <div class="list_projects_section_in_dashboard">
                    <ul class="list_of_projects row">
                        <li class="col-md-15 col-sm-3" ng-repeat="wd in workOrdersList | filter:search">
                            <a ng-click=" viewProject(wd)" href=" ">
                                <img src="./images/projectthumb.jpg" />
                                <h4>{{wd.name}}</h4>
                            </a>
                            <p>Status: {{wd.status}}</p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div><!--end of tab content-->

没有错误,但它不显示任何内容。它与ng-repeat一起工作,但在我使用filter时不知何故。当我检查DOM时,它显示:

<ul class="list_of_projects row">
    <!-- ngRepeat: wd in workOrdersList | filter:search -->
</ul>

为什么会被评论出来?奇怪。我无法弄清楚

1 个答案:

答案 0 :(得分:0)

将过滤器从filter: search更改为filter: search.status