2014-02-25 35 views
0

鉴于简单的路由例如:如何通过更新AngularJS中的路径元素来更改位置?

.when('/invoices/page/:number', { 
    templateUrl: 'invoices-list.html', 
    controller: InvoiceController, 
    resolve: InvoiceController.resolve 
}) 

如何设置位置,以给定的页面,无需手动设置的完整路径。我明显可以做$location.path('/invoices/page/' + $scope.currentPage);,但我想重复使用其他资源的机制,并避免直接与字符串混淆。

当页码是一个搜索参数时,它是微不足道的,那么它足以使用$location.search("number", $scope.currentPage)如果参数是路径的一部分,重定向是否有同样的方法?

回答

0

试试这个

$location.$$path='/invoices/page/' + $scope.currentPage; 

,如果你想重新加载页面,然后用下面的代码

$route.reload(); 
+0

使用,你甚至看问题,或者仅仅是标题? – mdrozdziel