相关疑难解决方法(0)

如何在Angular 2中使用DataTable

我想在我的Angular 2应用程序中使用DataTable.但这不起作用.Angular 2中没有可能在模板中添加脚本标记.你知道我怎么能这样做吗?我想我必须在systemJs中做一些改变.

list.html:

<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
        <tbody>
              <tr>
                <td>Gavin Cortez</td>
                <td>Team Leader</td>
                <td>San Francisco</td>
                <td>22</td>
                <td>2008/10/26</td>
                <td>$235,500</td>
            </tr>
            <tr>
                <td>Martena Mccray</td>
                <td>Post-Sales support</td>
                <td>Edinburgh</td>
                <td>46</td>
                <td>2011/03/09</td>
                <td>$324,050</td>
            </tr>
        </tbody>
    </table>
Run Code Online (Sandbox Code Playgroud)

我的组件:

...
declare var jQuery:any;
..
ngOnInit():any{
       console.log("Augerufen");
       jQuery('#example').DataTable();
   }
...
Run Code Online (Sandbox Code Playgroud)

在我的index.html中,我添加了所需的库:

<!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/jquery.dataTables.min.css" rel="stylesheet">
<!-- jQuery …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery datatables angular

4
推荐指数
1
解决办法
5695
查看次数

标签 统计

angular ×1

datatables ×1

html ×1

javascript ×1

jquery ×1