8

I have an angularjs (v 1.2.19) application that consists of two separate html pages (or actually these are two seperate angularjs apps in one folder):

  • index.html
  • edit.html

I am having some well-known compatibility issues on IE 8 and 9 (both do not support the html5 history API). My config contains: $locationProvider.html5Mode(true).hashPrefix('!');

I do not have any routing in the application - index.html and edit.html can be seen as separate angularjs apps - that have separate angularjs initialization, etc.

The problem looks like this: Whenever I open the link: http://server/app or http://server/app/index.html everything works fine.

Whenever I open the link: http://server/app/edit.html from ng-click or directly in the browser the page is automatically redirected to http://server/#!app/edit.html

How can I disable the "hashbang" redirection? Edit.html is not a part of the index.html, so it should be loaded directly without any index.html redirection and "hash" routing.

I tried the code located below, but it leads to infinite loop of redirections...

<!--[if lt IE 10]>
    <script>   
        window.location = window.location.href.replace( /#.*/, "");
    </script>
<![endif]-->

Any help appreciated.

tom.bujok
  • 1,612
  • 2
  • 13
  • 20
  • 1
    Maybe it needs to be tweaked on server side (rewriting in html5 mode). There is a FAQ entry about that in ui-router project, see https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode Hope this helps. – Michal Ostruszka Jul 17 '14 at 08:06
  • Thanks for the hint. I do not get, however, what should I rewrite to what. In the end the problem boils down to the fact, that I've got an angular app, that's not under index.html. Whenever I try to open that link in the IE8/IE9 browser the links get rewritten by angular and the # is added. What should be the link that I should rewrite to using Apache2, etc? – tom.bujok Jul 17 '14 at 09:33
  • possible duplicate of [10 $digest() iterations reached. Aborting! when using $locationProvider.html5Mode(true);](http://stackoverflow.com/questions/17146461/10-digest-iterations-reached-aborting-when-using-locationprovider-html5mod) – Paul Sweatte Dec 27 '14 at 03:57
  • How about making a directive that makes sure the full window redirect will happen? It could be an attribute you add to an tag that watches for clicks and forces the window.location to this.href? – sergiocruz Jan 16 '15 at 19:55

1 Answers1

-1

Try to disable html5mode $locationProvider.html5Mode(false).hashPrefix('!'); or remove this string completely.

dnemoga
  • 214
  • 3
  • 5