Created
May 22, 2019 16:43
-
-
Save euglv/4fde41f2bba1c2fd1914e09baad02a08 to your computer and use it in GitHub Desktop.
Aurelia Gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h1>${message}</h1> | |
<router-view></router-view> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
message = 'Hello World!'; | |
configureRouter(config, router) { | |
const homeStratagy = (instruction) => { | |
if (instruction.queryParams.key) { | |
instruction.config.moduleId = 'search'; | |
} else { | |
instruction.config.moduleId = 'landing'; | |
} | |
if (instruction.config.viewPorts) | |
instruction.config.viewPorts.default.moduleId = instruction.config.moduleId; | |
console.log('homeStratagy:', instruction); | |
}; | |
config.map([ | |
{route: '', name: 'home', navigationStrategy: homeStratagy} | |
]); | |
this.router = router; | |
} | |
/*determineActivationStrategy(params, routeConfig, navigationInstruction){ | |
console.log('determineActivationStrategy:', {params, routeConfig, navigationInstruction}); | |
return 'invoke-lifecycle'; | |
} /**/ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
Landing! | |
<br> | |
<button click.trigger="goto()">Show dynamic page with random key</button><br> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { inject } from 'aurelia-framework'; | |
import { Router } from 'aurelia-router'; | |
@inject(Router) | |
export class Landing { | |
constructor(router) { | |
this.router = router; | |
} | |
activate(params) { | |
this.params = params; | |
console.log("Landing activate:", params); | |
} | |
goto(){ | |
this.router.navigateToRoute('home', {key: Math.random()}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
Search!<br> | |
Key: ${params.key}<br> | |
<button click.trigger="home()">Go home</button> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { inject } from 'aurelia-framework'; | |
import { Router } from 'aurelia-router'; | |
@inject(Router) | |
export class Search { | |
params = {}; | |
constructor(router) { | |
this.router = router; | |
} | |
activate(params) { | |
this.params = params; | |
console.log("Search activate:", params); | |
} | |
home(){ | |
this.router.navigateToRoute('home'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment