如何更新角度智能表中的过滤器

时间:2016-01-05 14:25:57

标签: angularjs smart-table

我想存储智能表的最后一个搜索/过滤器。这样可以正常工作,但表格在重新加载时不会更新过滤器。

查看http://plnkr.co/edit/PUNLuzZHUMF4MUadYg3K?p=preview

HTML格式的控制器:

<div data-ng-controller="TestController">
  <table class="table table-striped" data-st-safe-src="store.getItems()" data-st-table="displayedCollection">
    <thead>
      <tr>
        <th data-st-sort="lastname">Name</th>
        <th data-st-sort="company">Company</th>
        <th data-st-sort="customerno">Customer No.</th>
      </tr>
      <tr>
        <th colspan="999">
          <div class="row">
            <div class="col-md-11">
              <input type="search" data-ng-change="updateSearchPattern()" data-ng-model="search" placeholder="search" class="form-control" data-st-search="" />
              <div class="col-md-1">
                <button type="button" class="btn btn-danger btn-sm">
                  <span class="glyphicon glyphicon-remove"></span>
                </button>
              </div>
            </div>
          </div>
        </th>
      </tr>
    </thead>
    <tbody>
      <tr data-ng-repeat="row in displayedCollection" data-st-select-mode="single" data-st-select-row="row">
        <td>{{row.lastname}}, {{row.surname}}</td>
        <td>{{row.company}}</td>
        <td>{{row.customerno}}</td>
      </tr>
    </tbody>
  </table>
</div>

我的控制员:

    testApp.controller('TestController', 
    ['$scope', 'DataService',
    function ($scope, service)
    {

        $scope.displayedCollection = [];

        $scope.store = service.getStore();

        $scope.updateSearchPattern = function()
        {
            service.setSearchPattern($scope.search);
        };

        $scope.search = service.getSearchPattern();

    }]);

0 个答案:

没有答案