angularJS:ui路由器,相当于$ location.search [英] angularJS: ui-router equivalent to $location.search
问题描述
我正在使用以下内容在数据网格中进行分页:
I'm using the following to do paging in my datagrid:
$location.search('page', page);
其中page是当前页码.
where page is the current page number.
然后我听以下事件:
$scope.$on('$routeUpdate', function(next, current) {
$scope.currentPage = $routeParams.page ? Number($routeParams.page) : 1;
$scope.search();
});
这会在更新URL中的currentPage之后触发我范围内对search()方法的调用.
That triggers a call to a search() method on my scope after updating the currentPage that is in the URL.
我如何使用ui-router将其转换为状态?由于我使用的是状态管理器而不是路由,因此不再触发$ routeUpdate.
How would I translate that to states with ui-router ? The $routeUpdate is no longer triggered since I'm using a state manager instead of routes.
我的路线现在在状态提供程序中定义如下:
My route is now defined in the state provider as such:
$stateProvider
.state('mandats', {
url: '/domiciliations/mandats',
templateUrl: 'domiciliations/views/mandats.html',
controller: 'mandatsCtrl'
})
推荐答案
我最终还是听了$ locationChangeSuccess事件,并解决了该问题.
I ended up listening to the $locationChangeSuccess event instead and that solved it.
这篇关于angularJS:ui路由器,相当于$ location.search的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!