Skip to content

Instantly share code, notes, and snippets.

@d13 d13/app.html
Last active Oct 16, 2018

Embed
What would you like to do?
Aurelia Gist - nav in a LayoutView
<template>
<require from="nav-bar.html"></require>
<!-- this nav works -->
<nav-bar router.bind="router"></nav-bar>
<div class="page-host" style="margin-top:50px">
<router-view router.bind="router"></router-view>
</div>
</template>
export class App {
configureRouter(config, router) {
config.title = 'Aurelia';
config.map([
{
layoutView: 'layout-foo.html',
route: ['', 'welcome'],
name: 'welcome',
moduleId: 'module-home',
nav: true,
title: 'Welcome'
}//,
//{ layoutView: 'alt-layout.html', route: 'welcome2', name: 'welcome2', moduleId: 'welcome', nav: true, title: 'Welcome Alt Layout' },
]);
this.router = router;
}
}
<!doctype html>
<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://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
<template bindable="router">
<require from="nav-bar.html"></require>
<div>bar</div>
<!-- this nav does not work -->
<nav-bar router.bind="router"></nav-bar>
<div style="background-color:red;">
<slot name="main-content"></slot>
</div>
<div style="background-color:blue;">
<slot name="alt-content"></slot>
</div>
<div>baz</div>
</template>
<template>
<div slot="main-content">
hello world
</div>
<div slot="alt-content">
hello world 2
</div>
</template>
export class ModuleHome {
message = 'Hello World';
}
<template bindable="router">
<nav class="navbar navbar-light">
<div class="nav navbar-nav">
<span>Foo</span>
<a repeat.for="row of router.navigation" href.bind="row.href"
class="nav-item nav-link ${row.isActive ? 'active' : ''}">
${row.title}
</a>
</div>
</nav>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.