我排序数据表时遇到一些小问题。我对我的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>
你的排序代码在哪里? –
你使用角度数据表指令? – MMK