javascript - AngularJS reload page function and automatic log out conflict each other -


i writing app uses angularjs , ui-router. have button refreshes page reloading page, , functionality automatically logs users out when window or tab closed. both functions work awesome (and done using traditional javascript make things simple). see below:

<script>       // refreshes reloading page       function refresh() {           location.reload();       }        // automatically logs users out when browser or tab closed       window.onunload = function(){           localstorage.clear();       } </script> 

however, problem when reload button clicked logs current user out , not want. want user logged out when window closed. there anyway can done? reloading route in controller fix problem?

not solution can use global flag can set when reloading page

var refh = false; function refresh(){   ref = true;   location.reload() }  window.unonload = function(){   if(!refh)    localstorage.clear(); } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -