I am new in angularJS .. when I delete row from table, i want to show next one from next page to keep rows number = 3 (for example)..
html :here are parts of codes :
<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;
};
I read about $routeProvider
and routing between pages, but i didnt know how to use it with pagination,, so if the routing is the solution, how to do it in my code?
thanx alot ...
plunker : http://plnkr.co/edit/6GnDdNesbfoy2VbdF2Cr?p=preview