Skip to content

Instantly share code, notes, and snippets.

@charlespockert
Last active May 16, 2016 15:13
Show Gist options
  • Save charlespockert/b9628a0179c9aeabccd5b32ff972ee95 to your computer and use it in GitHub Desktop.
Save charlespockert/b9628a0179c9aeabccd5b32ff972ee95 to your computer and use it in GitHub Desktop.
export class AppConfig {
routes = [
{
route: [''],
name: 'route1',
moduleId: './route1',
title: 'Route 1'
}
]
}
<template>
<router-view></router-view>
</template>
import {inject} from 'aurelia-framework';
import {AppConfig} from './app-config';
@inject(AppConfig)
export class App {
constructor(appConfig) {
this.config = appConfig;
}
configureRouter(routerConfig, router) {
this.router = router;
routerConfig.map(this.config.routes);
}
}
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export class Route1Config {
routes = [
{
route: [''],
name: 'route2',
moduleId: './route2',
title: 'Route 2'
}
];
}
<template>
<router-view></router-view>
</template>
import {inject} from 'aurelia-framework';
import {Route1Config} from './route1-config';
@inject(Route1Config)
export class Route1 {
constructor(route1Config) {
this.config = route1Config;
}
configureRouter(routerConfig, router) {
this.router = router;
routerConfig.map(this.config.routes);
}
}
import {inject} from 'aurelia-framework';
import {Router} from 'aurelia-router';
@inject(Router)
export class Route2Config {
}
<template>
<span repeat.for="b of breadcrumb">${b.config.name}<span if.bind="!$last"> | </span></span>
</template>
import {inject} from 'aurelia-framework';
import {Route2Config} from './route2-config';
import {Router} from 'aurelia-router';
@inject(Route2Config, Router)
export class Route2 {
breadcrumb = [];
constructor(route2Config, router) {
this.configApp = route2Config;
this.router = router;
}
attached() {
var inst = this.router.currentInstruction;
while(inst) {
this.breadcrumb.push(inst);
inst = inst.parentInstruction;
}
this.breadcrumb.reverse();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment