我有一个问题。在Angular.js中使用分页时我需要返回到同一页面。让我来解释代码和场景。
<div class="row" ng-show="showForm">
<form name="billdata" id="billdata" enctype="multipart/form-data" novalidate>
<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right oditek-form" style="width:180px">Restaurant Name :</span>
<input type="text" name="colgname1" id="colgname1" class="form-control oditek-form" placeholder="Add Name" ng-model="name" ng-keypress="clearField('colgname1');" maxlength="50">
</div>
<input type="button" class="btn btn-red" ng-click="clearCustomerInfoData();" id="addProfileData" ng-value="ClearbuttonName" ng-show="showCancel"/>
</form>
</div>
<table class="table table-bordered table-striped table-hover" id="dataTable" >
<thead>
<tr>
<th>Edit</th>
<th>Remove</th>
</tr>
</thead>
<tbody id="detailsstockid">
<tr dir-paginate="cus in ($parent.labelResults=(listOfCustomerData | filter:searchProduct.rest_name | orderBy:'rest_name')) | itemsPerPage:5 track by $index" current-page="currentPage">
<td >
<a ui-sref="dashboard.customer.view">
<input type='button' class='btn btn-xs btn-green' value='Edit' ng-click="editProductViewData(cus.member_id);">
</a>
</td>
<td>
<a ui-sref="dashboard.customer.view">
<input type='button' class='btn btn-xs btn-red' value='Delete' ng-click="deleteProductInfoData(cus.member_id);" >
</a>
</td>
</tr>
</tbody>
</table>
<div class="pull-right">
<dir-pagination-controls max-size="5" direction-links="true" boundary-links="true" >
</dir-pagination-controls>
</div>
此处我使用dir-paginate
进行分页.suppose用户位于3
页面中,点击edit
按钮后,表单将打开下面的代码。
$scope.editProductViewData=function(memberid){
$scope.showForm=true;
$scope.ClearbuttonName="Cancel";
$scope.showCancel=true;
}
但是我在最近的情况下点击表单内的Cancel
按钮,它将返回到1st
页面。代码如下所示。
$scope.clearCustomerInfoData=function(){
$state.go('dashboard.customer.view',{}, { reload: true });
}
我的配置文件如下所示。
var Admin=angular.module('Spesh',['ui.router', '720kb.datepicker','ngMessages','ngCapsLock','ui.bootstrap','ngFileUpload','angularUtils.directives.dirPagination']);
Admin.run(function($rootScope, $state) {
$rootScope.$state = $state;
});
Admin.config(function($stateProvider, $urlRouterProvider,$locationProvider) {
$urlRouterProvider.otherwise('/');
.state('dashboard', { /* This state defines The root admin login page. */
url: '/dashboard',
templateUrl: 'dashboardview/dashboard.html',
controller: 'adminController'
})
.state('dashboard.customer', {
url: '/customer',
templateUrl: 'dashboardview/customer.html',
controller: 'adminCustomerController'
})
.state('dashboard.customer.new', {
url: '/new',
templateUrl: 'dashboardview/customerNew.html',
controller: 'adminCustomerNewController'
})
.state('dashboard.customer.view', {
url: '/view',
templateUrl: 'dashboardview/customerView.html',
controller: 'adminCustomerViewController'
})
})
在这里,我需要假设用户在3rd
页面并点击编辑按钮,然后打开表单。当用户点击Cancel
按钮时,它应该返回到3rd
页面而不是第1页。请帮帮我。
答案 0 :(得分:0)
我认为,当前页面的值正在更新。 请提供有关您的控制器的更多信息。
在$watch
中应用$scope.currentPage
功能。
因为它可能设置为$scope.currentPage = 1