如何在 angular 2+ 中 reload/refresh 之前的 url?
how to reload/refresh previous url in angular 2+?
在我当前的 Angular 7 应用程序场景中,如果网络停止,我将导航用户到连接丢失组件。我正在使用 skipLocationChange:true
标志来执行此操作,如下面的
this.router.navigate(['/connection-lost'], {skipLocationChange: true});
现在网络开始工作了。我想通过单击 ConnectionLostComponent
.
中的重新加载按钮来重新加载上一页
我通过 router.navigate([router.url])
尝试过,但是 router.url
给出 URL /connection-lost
没有显示在 地址栏
例如,如果用户在地址页面 ('/addresses') 上,并且连接丢失。然后用户将导航到同一 URL('/addresses') 上的 ConnectionLostComponent
。现在如果用户点击重新加载按钮,那么它应该加载地址页面
我该怎么做?
我找到的一个解决方案是使用 Router
的 navigateByUrl
方法。
喜欢:
this.router.navigateByUrl(this.location.path(true));
here location
from ('@angular/common') 给出了地址栏.
中显示的确切路径
在我当前的 Angular 7 应用程序场景中,如果网络停止,我将导航用户到连接丢失组件。我正在使用 skipLocationChange:true
标志来执行此操作,如下面的
this.router.navigate(['/connection-lost'], {skipLocationChange: true});
现在网络开始工作了。我想通过单击 ConnectionLostComponent
.
我通过 router.navigate([router.url])
尝试过,但是 router.url
给出 URL /connection-lost
没有显示在 地址栏
例如,如果用户在地址页面 ('/addresses') 上,并且连接丢失。然后用户将导航到同一 URL('/addresses') 上的 ConnectionLostComponent
。现在如果用户点击重新加载按钮,那么它应该加载地址页面
我该怎么做?
我找到的一个解决方案是使用 Router
的 navigateByUrl
方法。
喜欢:
this.router.navigateByUrl(this.location.path(true));
here location
from ('@angular/common') 给出了地址栏.