简体   繁体   English

单击历史记录后退按钮时,angularjs ng-include不会重新加载

[英]angularjs ng-include does not reload when history back button is clicked

I have written a script which dynamically changes the ng-include source and loads a different template based on URL's with a hash (#). 我编写了一个脚本,该脚本可动态更改ng-include源,并基于带有散列(#)的URL加载不同的模板。

Example links are: 示例链接是:

example.com/test#template-1.html
example.com/test#template-2.html

Is there a way for ng-include to reload the template when the history back button is clicked. 单击历史记录后退按钮时, ng-include可以重新加载模板。 I do not wish to make use of ng-route at this point. 我现在不希望使用ng-route I just need to know if there is a way to do this with ng-include . 我只需要知道是否可以使用ng-include做到这一点。

您可以在JavaScript中使用“ onbeforeunload ”事件,并为ng-include变量设置值。

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

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