我是angularJS的新手..当我从表中删除行时,我想从下一页显示下一行以保持行数= 3(例如)..
html:这是代码的一部分:
<tbody id="t"> <!-- fetch data from DB -->
<tr id="tr-{{item.id}}" ng-repeat="item in ItemsByPage[currentPage]">
<td>
<div ng-model="tid"> {{item.id}} </div>
</td>
<td id="tdn-{{item.id}}">
<div ng-model="tname">{{item.name}} </div>
</td>
</tr>
</tbody>
<ul class="pagination">
<li><a href="#" ng-click="firstPage()">First</a></li>
<li ng-repeat="n in range(ItemsByPage.length)"><a href="#" ng-click="setPage()" ng-bind="n+1">1</a></li>
<li><a href="#" ng-click="lastPage()">Last</a></li>
</ul>
<div class="col-xs-4"> <!-- delete user -->
<input type="text" ng-model="delId" class="form-control" placeholder="Enter user id to delete the user">
<button ng-click="deleteuser(delId)" type="button" class="btn btn-primary">Delete User</button>
</div>
JS:
$scope.deleteuser = function (delId) {
var data = {delId : $scope.delId};
$http.post('delete.php', data )
.success(function(response) {
$("#tr-"+delId).hide();
console.log($("#tr-"+delId).next());
$("#tr-"+delId).next().show();// It doesnt work
});
$scope.resetAll();
};
$scope.setPage = function () {
$scope.currentPage = this.n;
};
$scope.firstPage = function () {
$scope.currentPage = 0;
};
$scope.lastPage = function () {
$scope.currentPage = $scope.ItemsByPage.length - 1;
};
我阅读了$routeProvider
和页面之间的路由,但我不知道如何使用分页,所以如果路由是解决方案,如何在我的代码中执行?
thanx很多...