All of our essential routes are configured and we now have access to separate partials for all of them. That’s great, but I’m not really happy with the routes following the # symbol in the URL. Thankfully, there’s an easy way to eradicate that, by enabling what Angular calls html5Mode.

The mode enables Angular to take advantage of pushState in modern browsers while still providing a fallback for legacy browsers, such as IE 8.

Enabling HTML5Mode

To enable the new mode, we need to look at our config method again. Like before, we’re going to need to inject a service into it:

.config(function($routeProvider, $locationProvider){

    ...

    $locationProvider.html5Mode(true);

})

You’ll notice that we’ve now injected a second service: …

Advertisements