AngularJS How to remove # # character in IE9 using route

I cannot remove the # character in IE9. I searched for an answer but did not find a fix.

It is always redirected to

http://myhost.com:8080/#/website/ 

and shows this description:

 The requested resource is not available. 

locationprovider.html5mode(true) does not work. The same route works in FireFox and shows

 http://myhost.com:8080/website/ 

How can i fix this?

+8
angularjs internet-explorer-9 using routes
source share
4 answers

IE9 does not support the html5 api history, so if you add # to the URL, deleting # will not solve your problem.

+6
source share

$ location Documentation

See "Hashbang and HTML5 Modes"

Basically, html5 mode uses the History API when the browser supports it, and returns to hashbang ( # ) when it is not supported.

You cannot "simply" delete "#" in a browser without a history API. Because when you change the URL, the browser will try to force a reboot, breaking the stream.

+6
source share

Actually we cannot remove this, but we can make it work smoothly

 RouterModule.forRoot(ROUTES, { useHash: Boolean(history.pushState) === false }); 
+1
source share

Using window.location.hash = '/' solved my problem.

 if (window.history && window.history.pushState) { $locationProvider.html5Mode(true); } else { window.location.hash = '/' // IE 9 FIX $locationProvider.html5Mode(true); } 
0
source share

All Articles