如何更改$ routeParams参数? [英] How to change $routeParams parameters?

查看:438
本文介绍了如何更改$ routeParams参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在访问以下网址: http://bazarak.af/#!/annonser/page=1& ...

Im accessing this url: http://bazarak.af/#!/annonser/page=1&...

.when("/annonser/:query",{
    templateUrl: '/views/search.php',
    controller: "Search"
})

我想获取page的值,并在url和routeParams中对其进行更改。

I would like to get the value of page and change it both in the url and in the routeParams.

要获取我尝试过的页面值

To get the page value I have tried

var pageNumber = $routeParams.page;  

并进行设置,我尝试过:

and to set it I have tried:

$routeParams ==> {page:5}

这些都不起作用。而且文档并没有真正帮助我。
我该怎么做?

None of this works. And the documentation is not really helping me. How can I do this?

推荐答案

使用$ location.path()设置新的URL路径。它也会在路线中反映出来。
您也可以只更改$ location.search来更改查询
阅读此文档
http://docs.angularjs.org/guide/dev_guide.services 。$ location

Use $location.path() to set new URL path. It will be reflected in routes as well. You can also just change $location.search to change your query Read this documentation http://docs.angularjs.org/guide/dev_guide.services.$location

这篇关于如何更改$ routeParams参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆