简体   繁体   English

单击后退按钮时重新加载页面angularjs

[英]Reload page when back button is clicked angularjs

I'm new to angularjs and I'm trying to get my page to reload and the controller to reload when I hit the back button. 我是angularjs的新手,我想在按下后退按钮时重新加载页面并重新加载控制器。 I'm using a nested UI-router and right now, the page doesn't reload and the controller isn't reloading when the back button is clicked. 我使用的是嵌套的UI路由器,现在,单击后退按钮时,页面不会重新加载,控制器也不会重新加载。

More specifically, when you're in a child state and you click the back button, I want the parent state and it's controller to be reloaded. 更具体地说,当您处于子状态并单击“后退”按钮时,我希望重新加载父状态及其控制器。 Any suggestions on how to approach this problem? 关于如何解决这个问题有什么建议吗? Thanks. 谢谢。

It's deliberately not reloading because that's usually inefficient and it thinks that's what you want. 故意不重新加载,因为通常效率低下,并且认为这就是您想要的。 When you have a nested state in ui-router, the parent is active at the same time as the child, so ui-router doesn't normally need to do this. 当您在ui-router中具有嵌套状态时,父级与子级同时处于活动状态,因此ui-router通常不需要这样做。 If necessary, you can listen for $stateChangeStart and call $state.reload() when necessary to do this. 如有必要,您可以侦听$stateChangeStart并在必要时调用$state.reload() Just bear in mind that as soon as your page loads you'll get a $stateChangeStart event fired, so make sure you don't go into an infinite loop! 只需记住,一旦页面加载,就会触发$stateChangeStart事件,因此请确保您不会陷入无限循环!

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

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