使用Angular.js分页后单击取消按钮后无法返回到同一页面

时间:2016-05-11 05:11:08

标签: angularjs pagination dirpagination

我有一个问题。在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页。请帮帮我。

1 个答案:

答案 0 :(得分:0)

我认为,当前页面的值正在更新。 请提供有关您的控制器的更多信息。

$watch中应用$scope.currentPage功能。

因为它可能设置为$scope.currentPage = 1