내 Angular 2 앱에서 DataTable을 사용하고 싶습니다. 그러나 이것은 효과가 없습니다. Angular 2에는 템플릿에 스크립트 태그를 추가 할 수 없습니다. 내가 어떻게 이럴 수 있니? 시스템에서 몇 가지 변경을해야한다고 생각합니다.DataTable을 각도 2로 사용하는 방법
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>
내 구성 요소 : 내 index.html을에서
...
declare var jQuery:any;
..
ngOnInit():any{
console.log("Augerufen");
jQuery('#example').DataTable();
}
...
내가 추가 한 필요한 libaries : 사전에
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/jquery.dataTables.min.css" rel="stylesheet">
<!-- jQuery -->
<script src="js/jquery.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
감사합니다!
작동하지 않는 기능은 무엇입니까? 당신이하려고하는 것이 명확하지 않다. 당신이 제공 한 코드가 데모 코드이며, 잘 동작한다. 또한 jquery를 사용하여 왜곡 된 이벤트를 처리하는 이유는 무엇입니까? – Pogrindis
테이블을 필터링하고 dataTables를 사용하면 쉽게이 작업을 수행 할 수 있습니다. 코드를 index.html에 넣습니다. 그러나 emedded test.html을 사용하면 jQuery 코드가 실행되지 않습니다. 나는 window.alert ("test")로 시도했다. 이벤트가 작동하지 않습니다. – hamras
Ok 템플릿에 스크립트 태그를 추가 할 수 없습니다. 각도 2로 삭제합니다 – hamras