AngularJs:使用过滤器选项搜索无法正常工作

时间:2015-06-11 06:06:35

标签: javascript asp.net-mvc angularjs angularjs-filter

我在angularjs中遇到过滤文字问题。

我有一个名为“projects”的项目JSON数组

[{ "projectId": 1, "Name": "TestProject", "openIssueCount": "5"}, { "projectId": 2, "Name": "TestProject1", "openIssueCount": "7"}, { "projectId": 3, "Name": "TestProject2", "openIssueCount": "8" }]

搜索过滤器的HTML

       <section class="vbox">
        <header class="header clearfix dk b-b b-light issueheader" style="padding-top: 0px; padding:5px;top:0;">
                <div class="input-group" style="margin-left: 0px !important;">
                     @*textbox for search*@
                    <input type="text" data-ng-model="query.Name" class="input-sm form-control input-s-sm" style="line-height: none !important;" placeholder="Search" />
                    <div class="input-group-btn">
                        <button class="btn btn-sm btn-default" data-ng-show="!query.length" style="line-height: none !important;">
                            <i class="fa fa-search"></i>
                        </button>
                        <button class="btn btn-sm btn-default" data-ng-show="query.length" data-ng-click="query=''" style="line-height: none !important;">
                            <i class="fa fa-times" title="Clear"></i>
                        </button>
                        <button class="btn btn-sm btn-bg btn-default" data-toggle="tooltip" data-placement="bottom" style="margin-left: 2px !important;"
                                data-title="Refresh" data-original-title="" title="">
                            <i class="fa fa-refresh"></i>
                        </button>
                    </div>
                </div>
            </div>

        </header>
        <section class="scrollable projectScroll">
            <div class="list-group no-radius no-border no-bg m-t-n-xxs m-b-none">
                <div data-ng-repeat="project in Projects | filter:query" href="#" class="list-group-item list-group-item-p ng-cloak activeProject"
                     data-ng-click="ViewIssues(project,'Issues')" data-ng-class="{active: project.ID == target}"
                     data-ng-cloak="" href="@Url.Action("Index", "Issues")">
                    <div class="text-lt font-bold">
                        <span class="project-heading">{{project.Name}}</span>
                    </div>
                    <small>Open Issues : </small><small class="text-danger">{{project.OpenIssueCount}}</small>
                    <a class="new-issue" href="javascript:void(0);" data-ng-click="CreateNewIssue(project,'Issues/New')" 
                    style="padding-top:4px;text-decoration:underline !important;margin-right:-5px !important;">New Issue</a>

                </div>
            </div>
        </section>
    </section>

我的搜索工作得很好,有时并不总是,我无法理解这背后的原因。实际上我有一个侧面板,我的项目列表在其中呈现。它存在于局部视图中。请说明为什么我的搜索总是不行。

0 个答案:

没有答案