Tuesday, February 3, 2015

Aurelia: HTML5 navigation

Those of you familiar with AngularJS HTML5Mode setting:
$locationProvider.html5Mode(true);
Know that setting this to true will allow your routes to display real URLs in the address bar instead of hashed anchors. So instead of:
http://localhost/#welcome

You would get:
http://localhost/welcome

To turn this on in Aurelia, the pushState option must be enabled. It can be added to your router config:
config.options.pushState = true;
import {Router} from 'aurelia-router'; export class App { static inject() { return [Router]; } constructor(router) { this.router = router; this.router.configure(config => { config.title = 'Aurelia'; config.options.pushState = true; config.map([ {route: '', moduleId: 'views/index/index', nav: true, title: 'Home'}, {route: 'flickr', moduleId: 'views/flickr/index', nav: false, title: 'flickr'} ]); }); } }

No comments:

Post a Comment