1
votes

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. 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.

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.

1
Do you have URLs associated with the states? You will need them for the back button to work I believe. Also, when the back button is hit you will navigate to the previous URL (hence previous state if there is a previous URL), not necessarily the parent state/URL. You may be able to fix this by messing with the browser history using the history API (in modern browsers at least) but I'm not that familiar with trying to do that. - James Gaunt

1 Answers

0
votes

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. If necessary, you can listen for $stateChangeStart and call $state.reload() when necessary to do this. 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!