【发布时间】:2016-12-19 15:46:35
【问题描述】:
我在对数据表进行排序时遇到了一个小问题。我对我的api进行了查询,我很好地得到了我的数据,但是当我对界面进行排序时,数据消失了。一个想法?
JS
myApp.controller('MainCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('http://dev:5001/api/1/phones').
success(function(data, status) {
$scope.phones= data;
});
}]);
HTML
<div ng-app="myApp">
<div ng-controller="MainCtrl">
<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Id</th>
<th>IP_ADDRESS</th>
<th>MAC_ADDRESS</th>
<th>STATUS</th>
<th>VERSION</th>
</tr>
</thead>
<tbody>
<tr ng-repeat='phone in phones'>
<td> {{ phone.id }} </td>
<td> {{ phone.ip_address }} </td>
<td> {{ phone.mac_address }} </td>
<td> {{ phone.status }} </td>
<td> {{ phone.version }} </td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable({
"bPaginate": true,
"bLengthChange": false,
"bFilter": false,
"bInfo": false,
"bAutoWidth": true});
});
</script>
</div>
【问题讨论】:
-
您的排序代码在哪里?
-
你在使用角度数据表指令吗?
标签: angularjs datatables