Skip to content

Instantly share code, notes, and snippets.

@fabioluz
Created March 23, 2017 17:19
Show Gist options
  • Save fabioluz/0bf1e32cdccc37ceebc57c2d74ba2ca0 to your computer and use it in GitHub Desktop.
Save fabioluz/0bf1e32cdccc37ceebc57c2d74ba2ca0 to your computer and use it in GitHub Desktop.
<template>
<require from="./sidebar"></require>
<sidebar view-model.ref="sidebar"></sidebar>
<br><br>
<router-view></router-view>
</template>
import { Sidebar } from './sidebar';
import { Container, inject } from 'aurelia-framework';
@inject(Container)
export class App {
message = 'Hello World!';
constructor(container) {
this.container = container;
}
bind() {
this.container.registerInstance(Sidebar, this.sidebar);
}
configureRouter(config, router) {
config.map([{ route: '', name: 'route-1', moduleId: './route-1' }]);
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>
Route 1
</template>
import { Sidebar } from './sidebar';
import { inject } from 'aurelia-framework';
@inject(Sidebar)
export class Route1 {
constructor(sidebar) {
this.sidebar = sidebar;
this.sidebar.admin = false;
}
}
<template>
<div>
${admin ? 'admin' : 'no admin'}
</div>
</template>
export class Sidebar {
admin = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment