Skip to content

Instantly share code, notes, and snippets.

@thinkOfaNumber
Last active November 20, 2017 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save thinkOfaNumber/87aaf4c98b7276d88a8db84fcccecbc9 to your computer and use it in GitHub Desktop.
Save thinkOfaNumber/87aaf4c98b7276d88a8db84fcccecbc9 to your computer and use it in GitHub Desktop.
Aurelia router-view
<template>
First click one of these:
<ul>
<li repeat.for="i of 3" click.delegate="select(i)" class="${selected===i ? 'active' : ''}">Menu item ${i+1}</li>
</ul>
Now click a link:<br/>
<a route-href="route: page">Go to page</a><br/>
<a route-href="route: home">Go to home</a><br/>
Layout Contents:
<div class="layout">
<router-view></router-view>
</div>
</template>
export class App {
selected = null;
select(i) {
console.log("selecting " + i);
this.selected = i;
}
configureRouter(config, router){
config.map([
{ route: '', name: 'home', moduleId: 'home' },
{ route: 'page', name: 'page', moduleId: 'page' }
]);
this.router = router;
}
}
<template>
Home
</template>
export class Home {
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet">
</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://rawgit.com/jedd-ahyoung/aurelia-bundle/master/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
<template>
Page
</template>
export class Page {
}
.layout {
display: block;
border: 2px groove;
}
.legend {
display: block;
padding-left: 2px;
padding-right: 2px;
border: none;
}
.active {
text-decoration: underline;
text-transform: uppercase;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment