AngularJS ng-table reload in controller



我无法使用

 **$scope.tableview.reload()**
view.html is this.
 <div class="container-fluid" ng-controller="SearchListCtrl">
      <input ng-model="titleFilter"> Title Filter: {{ titleFilter }}
      <table ng-table="tableview" show-filter="true" class="table-responsive table table-striped table-bordered table-condensed table-hover">
        <thead>
          <tr><th colspan="3">Book Shelf</th></tr>
        </thead>
        <tbody>
          <tr ng-repeat="book in books | filter:titleFilter">
            <td><a href="#/data/{{$index + 1}}" ng-click="editBook(book)" class="thumb">{{$index + 1}}</a></td>
            <td class="col-sm-4">
              {{book.genre}}
            </td>
            <td class="col-sm-4">{{book.title}}</td>
            <td class="col-sm-4">{{book.author}}</td>
            <td>
                <button class="btn btn-danger btn-mini" ng-click="deleteRow($index)">
                    <i class="icon-trash icon-white"></i>
                </button>
          </tr>
        </tbody>
      </table>

控制器是这个

     librarysystemcontroller.controller('SearchListCtrl',
                                     ['$scope',
                                      'Library',
                                      'EditBookService',
                                      '$http',
                                      '$rootScope',
                                      function($scope,
                                               Library,
                                               EditBookService,
                                               $http,
                                               $rootScope) {
            $scope.tableview.reload();
        }]); 

@scope.tableview 未定义。这是不允许的吗?其他模型元素(如 ng-model)是可访问的。

Error is this. Is there a problem with the HTML ?
TypeError: Cannot read property 'reload' of undefined

更新:我认为我目前的表格足以满足我的目的。 ng-table 似乎需要一些我不需要的配置。

在你的

控制器中输入这个"ngTableParams"

librarysystemcontroller.controller('SearchListCtrl',
                                     ['$scope',
                                      'Library',
                                      'EditBookService',
                                      '$http',
                                      '$rootScope',
                                      function($scope,
                                               Library,
                                               EditBookService,
                                               $http,
                                               $rootScope,ngTableParams) { 

最新更新