Skip to content

Instantly share code, notes, and snippets.

@davismj
Created August 7, 2017 10:58
Show Gist options
  • Select an option

  • Save davismj/01786388db5ae6cf241c6b604e18461b to your computer and use it in GitHub Desktop.

Select an option

Save davismj/01786388db5ae6cf241c6b604e18461b to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<div>
date is ${date}
</div>
<div>
myClass.date is ${myClass.date}
</div>
<div>
Object.is(date, myClass.date) is ${is(date, myClass.date)}
</div>
<h2>Router View</h2>
<router-view></router-view>
</template>
import { inject } from 'aurelia-framework';
import { MyClass } from './myClass';
@inject(MyClass)
export class App {
constructor(myClass) {
this.date = new Date();
this.myClass = myClass;
}
configureRouter(config, router) {
config.map([
{ route: '', redirect: 'a' },
{ route: 'a', moduleId: 'myViewModelA' },
{ route: 'b', moduleId: 'myViewModelB' }
]);
}
is(a, b) {
return Object.is(a, b);
}
}
<!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>
import { inject } from 'aurelia-framework';
@inject(Date)
export class MyClass {
constructor(date) {
this.date = date;
}
}
<template>
<h2>Route A</h2>
<div>Date is: ${date.toGMTString()}</div>
<a href="#/b">Navigate to B</a>
</template>
import { inject } from 'aurelia-framework';
@inject(Date)
export class MyViewModelA {
constructor(date) {
this.date = date;
}
}
<template>
<h2>Route B</h2>
<div>Date is: ${date.toGMTString()}</div>
<a href="#/a">Navigate to A</a>
</template>
import { inject } from 'aurelia-framework';
@inject(Date)
export class MyViewModelB {
constructor(date) {
this.date = date;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment