AngularJS фильтр searchText не фильтрует - PullRequest
0 голосов
/ 03 августа 2020

Я пытаюсь реализовать ту же функцию поиска, что и в этом коде в списке, полученном через REST API SharePoint. Я не получаю сообщений об ошибках, но поиск ничего не дает. Спасибо.

AngularJS код

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

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

1 Ответ

0 голосов
/ 03 августа 2020

Я исправил это, выполнив следующие действия. Удален $ scope.searchText из контроллера. Теперь контроллер выглядит так:

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);
            });
        });
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...