IgorCh
IgorCh

Reputation: 2661

Angularjs, remove # from url in IE

I have following problem. On client side I have angular routing, something like that:

...
$locationProvider.html5Mode(true);
    $routeProvider.
        when('/item/:item_id', { reloadOnSearch: false, templateUrl: '/views/main/partials/_item.html', controller: ItemCtrl }).
        otherwise({redirectTo: '/login'}); // Default
...

and some routing on server side on PHP

$req=$_SERVER['REQUEST_URI'];
if(strpos($req,'/login') > -1){
    include __DIR__.'/../views/login/index.php';
} else if(strpos($req,'/item/') > -1) {
    include __DIR__.'/../views/item/index.php';
else {
    include __DIR__.'/../views/login/index.php';
}

all works great except IE, Because when client routing is executed on IE, url is changed from this one

myapp/item/123

to something like this

myapp/#/item/123

and when server side receives this kind of request url after client routing, all data after hash tag are gone and I cannot distinguish which route should be used. Can I remove # from the url, or do something else to make IE and server side live in peace? I failed in attempts to solve it. Thanks

Upvotes: 0

Views: 472

Answers (1)

Minko Gechev
Minko Gechev

Reputation: 25682

Your version of IE does not support HTML5 History API. To send the hash you should do some extra work for example do additional ajax request on $routeChangeStart.

Upvotes: 2

Related Questions