Basic Route Configuration Example : TypeScript
import {RouterConfiguration, Router} from 'aurelia-router';
export class App {
configureRouter(config: RouterConfiguration, router: Router): void {
this.router = router;
config.title = 'Aurelia';
config.map([
{ route: ['', 'home'], name: 'home', moduleId: 'home/index' },
{ route: 'users', name: 'users', moduleId: 'users/index', nav: true },
{ route: 'users/:id/detail', name: 'userDetail', moduleId: 'users/detail' },
{ route: 'files*path', name: 'files', moduleId: 'files/index', href:'#files', nav: true }
]);
}
}
Route Pattern Options :
static routes
* ie 'home'
: Matches the string exactly.
parameterized routes
* ie 'users/:id/detail'
: Matches the string and then parses an id parameter. Your view-model's activate callback will be called with an object that has an id property set to the value that was extracted from the url.
wildcard routes
* ie 'files*path'
: Matches the string and then anything that follows it. Your view-model's activate callback will be called with an object that has a path property set to the wildcard's value.