javascript - On refresh remove hashbang from URL in angularjs -


when navigating site that's using angularjs when changing routes adds hashbang @ end , can resume state on refresh (which cool).

however in particular project on refresh load main route (like if there no hashbang).

is possible?

you can using either service or multiple controllers. easiest way imo set simple controller , service included on every page.

something this:

<div style='display:none;' ng-controller='refreshcontroller'></div> 

service:

.factory('redirect',function($rootscope){     var rscope={};     rscope.redirect=true;     rscope.set=function(){         rscope.redirect=false;     };     rscope.get=function(){         return rscope.redirect;     };     return rscope; }); 

controller:

function refreshcontroller($location,redirect){     if($location.path()=='/'){         redirect.set()     }     if(redirect.get()){         $location.path('/');     } } 

in nutshell, if on main page, set service variable on home page. long no refresh done, service variable state static. if refresh done , not on main page, service variable different, , user redirected main page.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -