简体   繁体   English

在单页应用程序中重新加载页面

[英]Reloading page in single page application

I am in the middle of building a single page application. 我正在构建一个单页应用程序。 I am in a situation in which I have a slider in one tab and implemented a google map api in another tab. 我处于一个选项卡中有一个滑块,而另一个选项卡中实现了一个Google Map API的情况。 I have implemented the slider using bootstrap carousel. 我已经使用引导轮播实现了滑块。 Now since this is a single page application when I am routing from one tab to another tab, slider is not working neither google map is coming up. 现在,由于这是一个单页应用程序,当我从一个选项卡路由到另一个选项卡时,滑块不起作用,两个Google地图都无法显示。 And after reloading the page everything is working fine. 重新加载页面后,一切工作正常。

I am trying find an alternate solution for this one. 我正在尝试为此找到替代解决方案。 I am trying to reload the tab once again once it's clicked. 单击后,我试图再次重新加载该标签。

<li class="nav-item">
   <a ng-click="reloadRoute()" class="nav-link" href="#/contact">Contact Us</a>
</li>

And in controller this is what I am trying 在控制器中,这就是我要尝试的

$scope.reloadRoute = function() {
       $route.reload();
    }

But it's not working. 但这不起作用。 After following the post and also the documentation looks like it's not possible to reload a single page in single page application once the entire application is loaded. 在遵循了这篇文章之后,文档也看起来一旦加载了整个应用程序就无法在单个页面应用程序中重新加载单个页面。 Is there any alternate solution for this ? 是否有其他替代解决方案? I am using AngularJS version 1.5.9 我正在使用AngularJS版本1.5.9

It would be wiser to learn how to integrate Google maps and the slider with the AngularJS framework than to reload the entire page. 学习如何将Google地图和滑块与AngularJS框架集成起来比重新加载整个页面更为明智。

If you must reload the page, use $window.location.reload(true) . 如果必须重新加载页面,请使用$window.location.reload(true)

For more information, see MDN Web API Reference - Location.reload 有关更多信息,请参见MDN Web API参考-Location.reload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM