O'Reilly logo

Learning Web Development with Bootstrap and AngularJS by Stephen Radford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

HTML5 routing or removing #

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required