Skip to content

Instantly share code, notes, and snippets.

@tkhyn
Last active May 1, 2016 01:42
Show Gist options
  • Save tkhyn/2fba7f5617dd490eef561a2c07c4f6b0 to your computer and use it in GitHub Desktop.
Save tkhyn/2fba7f5617dd490eef561a2c07c4f6b0 to your computer and use it in GitHub Desktop.
<template>
<router-view></router-view>
</template>
export class App {
configureRouter(config, router) {
config.title = 'app'
config.options.pushState = true;
config.options.hashChange = false;
config.map([
{ route: '', moduleId: 'page' },
]);
config.mapUnknownRoutes('page');
this.router = router;
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<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 function configure(aurelia) {
aurelia.use
.defaultBindingLanguage()
.defaultResources()
.history()
.router()
.developmentLogging();
aurelia.start().then(a => a.setRoot('app'));
}
<template>
<a href.bind='url'
dblclick.trigger="dblclick()">Double-click me</a>
<ul>
<li repeat.for="m of messages">${m}</li>
</ul>
</template>
const CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const N = CHARS.length;
export class Page {
messages = [];
activate(params, config, navigationInstruction) {
this.messages.push(`Activating "${navigationInstruction.fragment}"`);
}
get url() {
// generates a random absolute URL
// there is no # as we're using hashChange = false
var result = '/';
for (var i = 8; i > 0; --i) {
result += CHARS[Math.floor(Math.random() * N)]
};
return result;
}
dblclick() {
this.messages.push('You double-clicked');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment