我正在使用以下内容在我的数据网格中进行分页:
$location.search('page', page);
其中 page 是当前页码。
然后我听以下事件:
$scope.$on('$routeUpdate', function(next, current) {
$scope.currentPage = $routeParams.page ? Number($routeParams.page) : 1;
$scope.search();
});
这会在更新 URL 中的 currentPage 后触发对我范围内的 search() 方法的调用。
我如何将其转换为带有 ui-router 的状态?$routeUpdate 不再被触发,因为我使用的是状态管理器而不是路由。
我的路线现在在状态提供程序中定义如下:
$stateProvider
.state('mandats', {
url: '/domiciliations/mandats',
templateUrl: 'domiciliations/views/mandats.html',
controller: 'mandatsCtrl'
})