1

This will be a bit long, but i hope to make myself clear. Please ask if i've not explained a point well enough.

Using the following structure/setup, i've h\got everything to work in all browsers except IE9. For anything below, i don't need to provide support; the problem therefore lies with EI9. I am not using UI-router.

  1. Website URL http://domainname

  2. Internal page link 1 <a href="page1">page1</a> - clicking on this should land me to http://domainname/page1

  3. Internal page link 2 <a href="page2">page2</a> - clicking on this should land me to http://domainname/page2

  4. Base <base href="/">

  5. HTML5 mode enable $locationProvider.html5Mode(true)

  6. Relevant route config

.when('/',{ templateUrl : 'pages/homepage.html', controller : 'homepageController' }).when('/page1',{ templateUrl : 'pages/page1.html', controller : 'page1Controller' }).when('page2',{ templateUrl : 'pages/page2.html', controller : 'page2Controller' })

  1. PhP htaccess redirect RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L] - this is for when you go to the page directly, and not land on the index, thus not giving the routing mechanism a chance to take over

My IE9 problem

The above Website URL gets transformed into http://domainname/#/ - a /#/ gets inserted into the link - i want that gone because it causes the following issues:

  1. When accessing <a href="page1">page1</a> - the link i get sent to becomes http://domainname/#/page1 - but it load fine. The problem becomes evident when trying to access the page2 page from page1
  2. When accessing <a href="page2">page2</a> - the link i get sent to becomes http://domainname/#/page1/page2, when it should at the very worst be http://domainname/#/page2 - Angular adds the URL to the existing URL, as a sort of subroute. So on and so forth for other pages - the URL concatenates.

I'm thinking it's related to the fact that IE9 does not support HTML5 push/pop, which i'm guessing Angular uses. I'm not sure, i'm new to this. At the very least $locationProvider.html5Mode(true) is what's bugging IE9, from what i can tell.

I am currently stuck and will appreciate any help on the matter.

EDIT: The answer below IS a workable solution and i'll accept it a "solved issue" answer after further investigation. If you have the same issue, use it.

Radu Andrei
  • 1,075
  • 10
  • 19
  • IE9 do not support the history API so I do not think you will get ti to work the way youd like. http://caniuse.com/#feat=history – aCa Mar 25 '15 at 13:26
  • That was my take on it as well, however the Angular website says it offers support for IE9, therefore i'm guessing there must be another mode to configure angular. I can check browser History API and switch depending on support, but i'm not familiar with a way to configure Angular to not use History API, without having to change the structure of all my links. – Radu Andrei Mar 25 '15 at 13:30
  • I see here http://stackoverflow.com/questions/17829991/angularjs-how-to-remove-symbol-in-ie9-by-using-route that using window.location.hash = '/' might help. Worth a try? – aCa Mar 25 '15 at 13:42
  • @aCa Definitely worth a try. Will test it out later and if it woks, i'll let you know. Thank you! – Radu Andrei Mar 25 '15 at 13:53
  • @aca Nope, using the solution provided there's absolutely no change. – Radu Andrei Mar 26 '15 at 09:19
  • @RaduAndrei Do you solve your problem? I have the same issue. Also I tried `window.location.hash = '/' `, it didn't help. – Qianyue Apr 09 '15 at 11:25
  • @Qianyue No, i didn't manage to, unfortunately. – Radu Andrei Apr 09 '15 at 15:53
  • @RaduAndrei Can you look at my answer? I think it should resolve your problem. – Qianyue Apr 10 '15 at 11:11

1 Answers1

1

I have created this pluncker example for the angular 1.3 routing issue under ie9. You can run this example under ie9, it runs well.

Notice that the plunker example set the <base href = ""/> with document.location dynamically. For your contatenated url problem, I think that it may be the problem of <base href>. Setting to <base href="/" /> should resolve the problem.

I also create a repo in github for this issue (in fact, it is a problem of infinite $digest issue, but routing still works, see #9235). Your can test this sample. In this sample I set <base href="/app/" />, because the base url is app.

Hope help.

Qianyue
  • 1,767
  • 19
  • 24
  • Half way there i'd say. There's still the #/ added to the URL issue in ie9. IT IS a workable solution for a lack of a better alternative. Will circle back to this when my time allows to investigate further. Thank you for your help and for now, grab the up-vote :) – Radu Andrei Apr 10 '15 at 20:22
  • @RaduAndrei thx. Adding the hash isn't the problem, the routing will work fine. The problem is the infinite digest which may consume the ressources. – Qianyue Apr 10 '15 at 20:26