Skip to content

Instantly share code, notes, and snippets.

@AshleyGrant
Forked from fabioluz/app.html
Last active December 2, 2022 21:48
Show Gist options
  • Save AshleyGrant/00b8b3745a480fb04184e8440e8be8c5 to your computer and use it in GitHub Desktop.
Save AshleyGrant/00b8b3745a480fb04184e8440e8be8c5 to your computer and use it in GitHub Desktop.
<template>
About us!
</template>
export class About { }
<template>
<require from="./nav.html"></require>
<nav router.bind="router"></nav>
${message}
<hr>
<router-view></router-view>
</template>
export class App {
message = 'Hello World!';
configureRouter(config, router) {
config.title = "Super Secret Project";
config.map([
{ route: ["","login"], name: 'login', moduleId: "./login", nav: true, title: "Login" },
{ route: 'about', name:'about', moduleId: "./about", nav: true, title: "About" }
]);
this.router = router;
}
}
<template>
<require from="./nav.html"></require>
<nav router.bind="router"></nav>
${message}
<br>
<br>
<button click.delegate="goToScreen2()">Go To Screen 2</button>
<button click.delegate="logOut()">Log Out</button>
<hr>
<router-view></router-view>
</template>
import { inject, Aurelia } from 'aurelia-framework';
@inject(Aurelia)
export class Authorized {
message = "authorized";
constructor(aurelia) {
this.aurelia = aurelia;
}
configureRouter(config, router) {
config.title = "Super Secret Project";
config.map([
{ route: [ '', 'screen-1'], moduleId: "./screen-1", nav: true, title: "Screen 1" },
{ route: 'screen-2', name:'screen-2', moduleId: "./screen-2", nav: true, title: "Screen 2" }
]);
config.mapUnknownRoutes(instruction => {
return './screen-1';
});
this.router = router;
}
goToScreen2() {
this.router.navigateToRoute('screen-2');
}
logOut() {
this.aurelia.setRoot('./app')
.then((aurelia) => {
aurelia.root.viewModel.router.navigateToRoute('login');
});
}
}
<!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>
${message}
<br>
<button click.delegate="logIn()">Log In</button>
</template>
import { inject, Aurelia } from 'aurelia-framework';
@inject(Aurelia)
export class Login {
message = "Log In";
constructor(aurelia) {
this.aurelia = aurelia;
}
logIn() {
this.aurelia.setRoot('./authorized');
}
}
<template bindable="router">
<ul class="nav navbar-nav">
<li repeat.for="row of router.navigation" class="${row.isActive ? 'active' : ''}">
<a data-toggle="collapse" data-target="#skeleton-navigation-navbar-collapse.in" href.bind="row.href">${row.title}</a>
</li>
</ul>
</template>
<template>
${message}
</template>
export class Screen1 {
message = 'Screen 1';
}
<template>${message}</template>
export class Screen2 {
message = 'Screen 2';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment