什么是保持查询参数在AngularJS变化的看法时,最简单的方法是什么? [英] What is the simplest way to keep query parameters in AngularJS when changing views?

查看:123
本文介绍了什么是保持查询参数在AngularJS变化的看法时,最简单的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法视图之间链接时要保持查询参数我角?

Is there a simple way to keep the query parameters when linking between views i Angular?

当我使用ngHref,查询参数丢失:

When I use ngHref, the query parameters are lost:

<a ng-href='OtherPage'>Other page</a>

我从这个网址导航 HTTP://localhost/Page.html#/ STAT = 77698382 ,这样:<?code>的http://本地主机/ page.html即可#/ OtherPage 。

此解决方案,但它需要有一个明确的重定向功能:

This solution works, but it requires a function with an explicit redirect:

<a ng-click='redirectToOtherPage()'>Other page</a> 

$scope.redirectToOrderListPage = function() {
    $location.path('OtherPage');
};

有没有更声明的方式来做到这一点?

Is there a more declarative way to do it?

推荐答案

这两个彼此略有不同。我认为你正在寻找的code是:

those two are slightly different from one another. I think the code you're looking for is:

<a ng-href='#/OtherPage'>Other page</a>

HTTP://localhost/Page.html#/ STAT = 77698382 似乎关闭

您需要像这样的哈希标签之前,把你的查询字符串:

You need to put your querystrings before the hash tag like so:

http://localhost/Page.html?stat=77698382#/

然后当你在你的应用程序导航,查询字符串不会被取代。

Then as you navigate around your app, the queryString will not be replaced.

这篇关于什么是保持查询参数在AngularJS变化的看法时,最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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