Skip to content

Instantly share code, notes, and snippets.

@deap82
Last active December 10, 2017 16:41
Show Gist options
  • Save deap82/fbc968a7f95906a7ff2487c34f60eeb3 to your computer and use it in GitHub Desktop.
Save deap82/fbc968a7f95906a7ff2487c34f60eeb3 to your computer and use it in GitHub Desktop.
Aurelia Gist - life cycle log
<template>
<ul id="menu">
<li><a href="#/Welcome">Welcome</a></li>
<li><a href="#/Products">Products</a></li>
<li><a href="#/Contact">Contact</a></li>
</ul>
<div id="content">
<router-view></router-view>
</div>
</template>
export class App {
configureRouter(config, router) {
config.map([
{ route: '', redirect: 'Welcome' },
{ route: 'Welcome', name: 'Welcome', moduleId: 'page-welcome' },
{ route: 'Products', name: 'Products', moduleId: 'page-products' },
{ route: 'Contact', name: 'Contact', moduleId: 'page-contact' }
]);
}
}
import { inlineView, customElement } from 'aurelia-framework'
@inlineView('<template><div>Example Element</div></template>')
@customElement('example-element')
export class ExampleElement {
constructor() {
console.log('ExampleElement', 'constructor');
}
created(owningView) {
console.log('ExampleElement', 'created');
}
bind() {
console.log('ExampleElement', 'bind');
}
attached() {
console.log('ExampleElement', 'attached');
}
detached() {
console.log('ExampleElement', 'detached');
}
unbind() {
console.log('ExampleElement', 'unbind');
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css" />
</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>
<h1>Contact</h1>
</template>
export class Contact {
}
<template>
<h1>Products</h1>
</template>
export class Products {
}
<template>
<require from="./example-element"></require>
<h1>Welcome</h1>
<example-element></example-element>
</template>
export class Welcome {
activate() {
console.log('Welcome', 'activate');
}
created() {
console.log('Welcome', 'created');
}
bind() {
console.log('Welcome', 'bind');
}
attached() {
console.log('Welcome', 'attached');
}
detached() {
console.log('Welcome', 'detached');
}
unbind() {
console.log('Welcome', 'unbind');
}
}
html, html *, html *:before, html *:after {
box-sizing: border-box;
}
body {
padding: 0;
margin: 0;
font-family: sans-serif;
}
#content {
padding: 10px;
}
#menu {
background: #26418f;
color: white !important;
padding: 10px;
margin: 0;
}
#menu li {
display: inline-block;
}
#menu li + li {
margin-left: 10px;
border-left: 1px solid white;
padding-left: 10px;
}
#menu li a {
color: white;
text-decoration: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment