$elem.hide 不是 angular-datatable 中的函数

$elem.hide is not a function in angular-datatable

我想使用分页插件 angular-datatable 。我用 bower 安装了它,但它没有 work.It 给出以下错误

TypeError: $elem.hide is not a function at Object.showLoading (http://localhost:8000/vendor/angular-datatables.js:698:15) at postLink (http://localhost:8000/vendor/angular-datatables.js:47:31) at http://localhost:8000/vendor/angular.js:8783:44 at invokeLinkFn (http://localhost:8000/vendor/angular.js:8789:9) at nodeLinkFn (http://localhost:8000/vendor/angular.js:8289:11) at compositeLinkFn (http://localhost:8000/vendor/angular.js:7680:13) at compositeLinkFn (http://localhost:8000/vendor/angular.js:7684:13) at compositeLinkFn (http://localhost:8000/vendor/angular.js:7684:13) at compositeLinkFn (http://localhost:8000/vendor/angular.js:7684:13) at compositeLinkFn (http://localhost:8000/vendor/angular.js:7684:13)

我使用了零配置, 这是我使用的 html 代码

<table datatable="" class="row-border hover">
    <thead>
        <tr>
            <th>ID</th>
            <th>First name</th>
            <th>Last name</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>Foo</td>
            <td>Bar</td>
        </tr>
        <tr>
            <td>123</td>
            <td>Someone</td>
            <td>Youknow</td>
        </tr>
        <tr>
            <td>987</td>
            <td>Iamout</td>
            <td>Ofinspiration</td>
        </tr>
    </tbody>
</table>

我认为您添加 javascript 个文件的顺序有误。

您需要按此顺序添加

  1. JQUERY
  2. ANGULAR
  3. JQUERY DATA-TABLE
  4. ANGULAR DATA-TABLE

并且不要忘记将 datatables 模块添加到主模块中,

EX: angular.module('plunker', ['datatables']);

DEMO

简单 - 如果您在 angular.js 之后添加 jquery.js,然后剪切 jquery.js 并将其放在 angular.js 的顶部。

如果您使用的是 bower,请更新 bower.json 以满足上述更改。

此外,请确保您没有将 ng-jq 指令设置为空。相反,您想将其设置为 $jQuery

<html id="ng-app" ng-jq="$">

<html id="ng-app" ng-jq="jQuery">