Skip to content

Instantly share code, notes, and snippets.

@swalters
Last active November 22, 2016 00:53
Show Gist options
  • Save swalters/c6fc3a019cce20bca3dee6d7dfc856cf to your computer and use it in GitHub Desktop.
Save swalters/c6fc3a019cce20bca3dee6d7dfc856cf to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<require from="./comp1"></require>
<button click.delegate="toggleComp1()">Toggle Comp1</button>
<div if.bind="showComp1">
<comp1></comp1>
</div>
</template>
export class App {
messages = ['foo', 'bar'];
constructor () {
window.setTimeout(() => this.messages.push('baz'), 2000)
}
toggleComp1(){
this.showComp1 = !this.showComp1;
}
}
export class FilterValueConverter {
toView (values) {
return values.filter(value => value[0] === 'b')
}
}
<template>
<require from="./comp2"></require>
<comp2
callee.call="callMe()"></comp2>
</template>
import {bindable} from 'aurelia-framework'
export class Comp1 {
constructor () {
}
callMe(){
console.log('I was called')
}
}
<template>
<div>
<button click.delegate="onClick()">Call Comp1</button>
</div>
</template>
import {bindable, customElement} from 'aurelia-framework'
@customElement('comp2')
export class Comp2 {
@bindable()
callee;
constructor () {
}
onClick(){
this.callee();
}
}
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment