Today in the project encountered a very strange problem, the use of oclazyload lazy load angular module, refresh the page, click the rollback button can not return to the previous page. It is estimated that the lazy loading mechanism destroys the State association within the angular, resulting in the inability to return to the previous state (Click the rollback button Ui-routre $stateChangeStart event will not be triggered), of course, this is only a guess, because the incident relationship did not go into depth to explore the source code.
Solution for angular lazy loading mechanism that cannot be rolled back after refreshing:
By looking at the angular (ionic) source, $browser has a Onurlchange method on this service, and when we change the URL address from outside of the angular, we call the event handler that is registered in this method, as shown in the following figure:
In this case, you can register a function at the program entry
When you jump to state through the browser fallback/forward button, the page is reloaded, and if you use System state, it will not go into this method
$browser. Onurlchange (function (URL) {
//todo Parsing the state in the URL, using lazy load to load the state module, implementation page Refresh
};
This function allows you to refresh the page again when you go back and forward ...
The above is a small set to introduce the angular lazy loading mechanism refresh can not be returned after the rapid solution, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!