更改路由参数而不在 Angular 2 中重新加载 [英] Change route params without reloading in Angular 2

查看:26
本文介绍了更改路由参数而不在 Angular 2 中重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Angular 2、谷歌地图等制作房地产网站,当用户更改地图中心时,我会搜索 API,指示地图的当前位置以及半径.问题是,我想在不重新加载整个页面的情况下在 url 中反映这些值.那可能吗?我找到了一些使用 AngularJS 1.x 的解决方案,但没有找到关于 Angular 2 的解决方案.

I'm making a real estate website using Angular 2, Google Maps, etc. and when a user changes the center of the map I perform a search to the API indicating the current position of the map as well as the radius. The thing is, I want to reflect those values in the url without reloading the entire page. Is that possible? I've found some solutions using AngularJS 1.x but nothing about Angular 2.

推荐答案

你可以使用 location.go(url) 这基本上会改变你的 url,而不会改变应用程序的路线.

You could use location.go(url) which will basically change your url, without change in route of application.

注意这可能会导致其他影响,例如从当前路由重定向到子路由.

NOTE this could cause other effect like redirect to child route from the current route.

描述 location.go

Related question 不会与 Router 密切相关以进行更改.

Related question which describes location.go will not intimate to Router to happen changes.

这篇关于更改路由参数而不在 Angular 2 中重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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