首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS searchText筛选器不筛选

AngularJS searchText筛选器不筛选
EN

Stack Overflow用户
提问于 2020-08-03 13:42:29
回答 1查看 21关注 0票数 0

我正尝试在通过SharePoint REST API获取的列表上实现与此codepen相同的搜索功能。我没有收到错误消息,但搜索没有执行任何操作。谢谢。

AngularJS代码

代码语言:javascript
复制
var app = angular.module('myApp', []);

app.controller('sopController',
        function($scope, $http) {
            $http({
                method: 'GET',
                url: "https://.../org/eu/EU3/EU34/_api/web/GetFolderByServerRelativeUrl('Goverance Library/SOP')/Files",
                headers: {"Accept": "application/json;odata=verbose"}
            }).then(function (data, status, headers, config) {

                $scope.sop_files = data.data.d.results;
                $scope.searchText = "";

            }, function errorCallback(response) {
                console.log(response);
            });
        });

HTML

代码语言:javascript
复制
                <div role="tabpanel" class="tab-pane fade show active" id="tab1">
                  <h3 style="float: left;">Standard Operating Procedures</h3><span style="float: right; padding: 2px;">Search: <input type="text" ng-model="searchText"></span>
                  <div class="SOP" ng-controller="sopController">
                    <table class="table table-striped table-hover">
                        <tr class="table_row" ng-repeat="file in sop_files | filter:searchText ">
                            <td><a ng-href="{{file.ServerRelativeUrl}}" target="_blank">{{file.Name}}</a></td>
                        </tr>
                    </table>
                </div>
                </div>
EN

回答 1

Stack Overflow用户

发布于 2020-08-03 14:19:59

我通过执行以下操作修复了它。已从控制器中卸下$scope.searchText。控制器现在看起来像这样:

代码语言:javascript
复制
app.controller('sopController',
        function($scope, $http) {
            $http({
                method: 'GET',
                url: "https://.../org/eu/EU3/EU34/_api/web/GetFolderByServerRelativeUrl('Goverance Library/SOP')/Files",
                headers: {"Accept": "application/json;odata=verbose"}
            }).then(function (data, status, headers, config) {
                $scope.sop_files = data.data.d.results;

            }, function errorCallback(response) {
                console.log(response);
            });
        });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63224272

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档