更改视图时,在AngularJS中保留查询参数的最简单方法是什么?
发布时间:2020-12-17 17:18:24 所属栏目:安全 来源:网络整理
导读:有没有一种简单的方法来保持查询参数在视图之间链接时Angular? 当我使用ngHref时,查询参数会丢失: a ng-href='OtherPage'Other page/a 我从这个网址http://localhost/Page.html#/?stat = 77698382导航到:http://localhost/Page.html#/OtherPage. 此解
有没有一种简单的方法来保持查询参数在视图之间链接时Angular?
当我使用ngHref时,查询参数会丢失: <a ng-href='OtherPage'>Other page</a> 我从这个网址http://localhost/Page.html#/?stat = 77698382导航到:http://localhost/Page.html#/OtherPage. 此解决方案有效,但它需要具有显式重定向的函数: <a ng-click='redirectToOtherPage()'>Other page</a> $scope.redirectToOrderListPage = function() { $location.path('OtherPage'); }; 有更多的声明方式吗? 解决方法
这两者略有不同.我认为您正在寻找的代码是:
<a ng-href='#/OtherPage'>Other page</a> http://localhost/Page.html#/?stat = 77698382似乎已关闭. 你需要将你的查询字符串放在哈希标记之前,如下所示: http://localhost/Page.html?stat=77698382#/ 然后,当您浏览应用程序时,不会替换queryString. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |