Last active
August 27, 2018 08:49
-
-
Save jmezach/b805a29cd56c07f4d3ba64f35d519a33 to your computer and use it in GitHub Desktop.
Aurelia Gist
This file contains 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> | |
<router-view></router-view> | |
<button click.delegate="click()">Replace</button> | |
</template> |
This file contains 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 { | |
configureRouter(config, router) { | |
this.router = router; | |
config.map([ | |
{ route: ['', 'home'], name: 'home', moduleId: 'page' }, | |
]); | |
} | |
click() { | |
console.log("Navigating"); | |
this.router.navigate('home', { replace: true }); | |
} | |
} |
This file contains 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://jmezach.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jmezach.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jmezach.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jmezach.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
This file contains 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> | |
<require from="./slot-component"></require> | |
<require from="./slot-item"></require> | |
<h1>Page</h1> | |
<slot-component> | |
<slot-item repeat.for="item of items"> | |
</slot-item> | |
</slot-component> | |
</template> |
This file contains 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 {activationStrategy} from 'aurelia-router'; | |
export class Page { | |
message = 'Hello World!'; | |
items = [{ | |
title: "Item1", | |
content: "Item 1 Content", | |
subitems: [ "SubItem 1", "SubItem 2" ] | |
}, { | |
title: "Item2", | |
content: "Item 2 Content", | |
subitems: [ "SubItem 3", "SubItem 4" ] | |
}, { | |
title: "Item3", | |
content: "Item 3 Content", | |
subitems: [ "SubItem 5", "SubItem 6" ] | |
}] | |
determineActivationStrategy() { | |
return activationStrategy.replace; | |
} | |
bind() { | |
console.log("[page] bind"); | |
} | |
attached() { | |
console.log("[page] attached"); | |
} | |
detached() { | |
console.log("[page] detached"); | |
} | |
unbind() { | |
console.log("[page] unbind"); | |
} | |
} |
This file contains 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> | |
<h2>Slot Component</h2> | |
<div> | |
<slot></slot> | |
</div> | |
</template> |
This file contains 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 SlotComponent { | |
bind() { | |
console.log("[slotcomponent] bind"); | |
} | |
attached() { | |
console.log("[slotcomponent] attached"); | |
} | |
detached() { | |
console.log("[slotcomponent] detached"); | |
} | |
unbind() { | |
console.log("[slotcomponent] unbind"); | |
} | |
} |
This file contains 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> | |
<div><slot name="a"></slot></div> | |
<div><slot name="b"></slot></div> | |
</template> |
This file contains 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 SlotItem { | |
bind() { | |
console.log("[slot-item] bind()"); | |
} | |
attached() { | |
console.log("[slot-item] attached()"); | |
} | |
detached() { | |
console.log("[slot-item] detached()"); | |
} | |
unbind() { | |
console.log("[slot-item] unbind()") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment