How to enable HTML5 routing in angularjs – quick tip

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){




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

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest