Skip to content

Instantly share code, notes, and snippets.

@davismj
Forked from AshleyGrant/app.html
Last active May 17, 2020 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davismj/040775f06aba5e955afd362ee60863aa to your computer and use it in GitHub Desktop.
Save davismj/040775f06aba5e955afd362ee60863aa to your computer and use it in GitHub Desktop.
Activation and Children Order
<template>
app
<router-view></router-view>
</template>
export class App {
configureRouter(config, router) {
this.router = router;
config.map([
{ route: '', redirect: 'parent' },
{ route: 'parent', name: 'parent', moduleId: 'parent', activationStrategy: 'invoke-lifecyle' }
])
}
activate() {
console.log('app', 'activate')
}
canActivate() {
console.log('app', 'canActivate')
}
}
<template>
child
</template>
export class ChildViewModel {
activate() {
console.log('child', 'activate')
}
canActivate() {
console.log('child', 'canActivate')
}
}
<!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>
parent
<router-view></router-view>
<a href="#/parent/child-1">one</a>
<a href="#/parent/child-2">two</a>
</template>
export class ParentViewModel {
configureRouter(config, router) {
this.router = router;
config.map([
{ route: '', redirect: 'child-1' },
{ route: 'child-1', name: 'child-2', moduleId: 'child', activationStrategy: 'invoke-lifecycle' },
{ route: 'child-2', name: 'child-2', moduleId: 'child', activationStrategy: 'invoke-lifecycle' }
])
}
activate() {
console.log('parent', 'activate')
}
canActivate() {
console.log('parent', 'canActivate')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment