IE9 PathLocationStrategy Angular 4

I am using IE9 and PathLocationStrategy with Angular4, but it does not seem to work. It simply adds “#" infinite time. I tried adding history.js polyfill but nothing works.

Can anyone help how to use PathLocationStrategy with Angular 4 and IE9?

Update: Finally, I realized that we cannot use PathLocationStrategy in IE9. Now I'm trying to figure out how to use PathLocationStrategy in the rest of the browser, and only if IE9 is present, switch to HashLocationStrategy. I tried to include the following line of code in my module:

RouterModule.forRoot(COMMON_ROUTES, { useHash: !Boolean(history.pushState) }), 

I confirmed that !Boolean(history.pushState) returns true in IE9 and false in other browsers. But that does not work. Angular is used by default for PathLocationStrategy even in IE9. Can anyone help?

+5
source share
1 answer

Cause

Older browsers [not evergreen] send page requests to the server if the location URL changes, if the change does not occur after the "#" (called the "hash"). Routers can use this exception by creating hash application URLs.


Decision

Unfortunately, there is no solution ...

As stated in the documentation , HashLocationStrategy is triggered during the boot process.

... you can switch to HashLocationStrategy with overriding during the boot process , if you prefer it.

This is further enhanced ...

You must choose a strategy, and you need to make the right call at the beginning of the project. This will not be easy to change later, once the application is in production, and there are many links to application URLs in the wild.

i.e. you need to develop content to use a specific location strategy, and changing strategies will mean that you will need to update significant logic and other routing functions at design time and not as subsequent / at run time as you want.

+2
source

Source: https://habr.com/ru/post/1271229/


All Articles