I have an HTML table that is dynamically loaded from an ng-repeat directive and am using Datatable-AngularJS to modify it. The table looks something like this:
<table datatable="ng" class="row-border hover">
<thead>
<tr>
<th>Song Name</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="song in Songs">
<td>{{song.song_name}}</td>
<td>{{song.song_type}}</td>
</tr>
</tbody>
</table>
</div>
Unfortunately, I keep getting an error in my console with TypeError: undefined is not a function. I THINK it's because of the way Angular-Datatables works. They ask you to include the bootstrapped files in this way:
<script src="jquery.min.js"></script>
<script src="jquery.dataTables.min.js"></script>
<script src="angular.min.js"></script>
<script src="angular-datatables.min.js"></script>
<script src="mybootstrap.js"></script>
But the thing is, when the datatables loads, the table has not been populated yet (because of the fact my bootstrapped js file is below that populates it. So I changed it to this:
<script src="jquery.min.js"></script>
<script src="jquery.dataTables.min.js"></script>
<script src="angular.min.js"></script>
<script src="mybootstrap.js"></script>
<script src="angular-datatables.min.js"></script>
But I still get the same error, when I put it like this:
<script src="angular.min.js"></script>
<script src="mybootstrap.js"></script>
<script src="jquery.min.js"></script>
<script src="jquery.dataTables.min.js"></script>
<script src="angular-datatables.min.js"></script>
I get a loading... that does nothing below and the raw html table is loaded. I have a feeling it has something to do with the async nature of AngularJS and that datatables is being loaded before the table is being populated by my bootstrapped js file. How can I fix this? Any ideas?