【问题标题】:Uncaught TypeError with bootstrap-table and angular with sever-side pagination带有引导表的未捕获的 TypeError 和带有服务器端分页的 Angular
【发布时间】:2015-10-30 14:59:29
【问题描述】:

我收到Uncaught TypeError: bsTable.$s.$applyAsync is not a function。 HTML页面代码:

<div ng-app="testapp">
  <div ng-controller="MainController">
    <table bs-table-control="dashboardTableControl"></table>
  </div>
</div>

Javascript 部分:

<script type="text/javascript">
  angular.module('testapp', ['bsTable'])
    .controller('MainController', function($scope, $http) {
      $scope.dashboardTableControl = {
        options: {
          url: "/tasks/",
          cache: false,
          height: 400,
          striped: true,
          pagination: true,
          pageSize: 10,
          pageList: [5, 10, 25, 50, 100, 200],
          search: true,
          showColumns: true,
          showRefresh: false,
          minimumCountColumns: 2,
          clickToSelect: false,
          showToggle: true,
          maintainSelected: true,
          sortName: "date_done",
          sidePagination: "server",
          columns: [{
            field: 'status',
            title: 'Status',
            sortable: true,
            editable: true,
            align: 'center'
          }, {
            field: '_id',
            title: 'Task ID',
            sortable: true,
            editable: true,
            align: 'center'
          }, {
            field: 'date_done',
            title: 'Date Completed',
            sortable: true,
            editable: true,
            align: 'center'
          }]
        }
      };
    });
</script>

我已将依赖项导入为:

<script type="text/javascript" src="/static/bower_components/bootstrap-table/src/bootstrap-table.js"></script>
<script type="text/javascript" src="/static/bower_components/bootstrap-table/dist/extensions/angular/bootstrap-table-angular.js"></script>

还有我的 bower.json:

"bootstrap-table": "1.9.0",
"angular": "~1.2.28",
"angular-route": "~1.2.28",
"angular-resource": "~1.2.28",

task api 也返回结果为:

{"rows": [{"status": "SUCCESS", "_id": "db672f91-cf56-4cf1-add2-216e7b069bbb", "date_done": "March 22, 2015 07:17:19 AM"}, {"status": "SUCCESS", "_id": "a44b670c-83c4-49ad-bbe4-11403c1b736e", "date_done": "March 22, 2015 07:17:29 AM"}, {"status": "SUCCESS", "_id": "ac60726e-edf7-4222-9cbb-88cfed5be69b", "date_done": "March 22, 2015 07:17:29 AM"}, {"status": "SUCCESS", "_id": "d3668982-bb3f-42b5-82eb-9b09ead36766", "date_done": "March 22, 2015 07:17:31 AM"}, {"status": "SUCCESS", "_id": "f97f89c1-53ff-4959-a2ad-2e7cfad37f48", "date_done": "March 22, 2015 07:17:41 AM"}, {"status": "SUCCESS", "_id": "84048949-ded1-4fe9-b699-d904c69d9d6c", "date_done": "March 22, 2015 07:17:42 AM"}, {"status": "SUCCESS", "_id": "3e06d66b-ba64-4d27-af8d-852356cd0063", "date_done": "March 22, 2015 07:17:44 AM"}, {"status": "SUCCESS", "_id": "82546768-461c-4474-9acb-0954e161e83c", "date_done": "March 22, 2015 07:17:52 AM"}, {"status": "SUCCESS", "_id": "92109e36-d27d-474a-a3e2-f34b743e3fbc", "date_done": "March 22, 2015 07:17:54 AM"}, {"status": "SUCCESS", "_id": "c4d6c39b-facc-4a88-8aa6-15753d7297ab", "date_done": "March 22, 2015 07:17:54 AM"}], "total": 109}

我哪里出错了??

【问题讨论】:

  • 你能创建 fiddle 还是 plunker。

标签: angularjs bootstrap-table


【解决方案1】:

我刚刚遇到同样的错误,我通过以下更改解决了

打开您的 bootstrap-table-angular.js 文件并将 $applyAsync 替换为 $evalAsync

它解决了错误,因为这是 Angular ^1.4 中的首选方法。

【讨论】:

    猜你喜欢
    • 2015-05-23
    • 2016-10-13
    • 2013-11-23
    • 2017-01-12
    • 2013-06-28
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 2015-07-15
    相关资源
    最近更新 更多