Skip to content

Instantly share code, notes, and snippets.

@brylie
Last active March 24, 2017 13:57
Show Gist options
  • Save brylie/71edadfe2404821c6aade147fcf8bf03 to your computer and use it in GitHub Desktop.
Save brylie/71edadfe2404821c6aade147fcf8bf03 to your computer and use it in GitHub Desktop.
Examples of working with events for the book -- Aurelia For Real World Web Applications available here: https://leanpub.com/aurelia-for-real-world-applications/
<template>
<h1>${counter} <button click.delegate="reset()">Reset</button></h1>
<h2>Increment</h2>
<button click.delegate="increment(1)">+ 1</button>
<button click.delegate="increment(5)">+ 5</button>
<button click.delegate="increment(100)">+ 100</button>
<h2>Decrement</h2>
<button click.delegate="decrement(1)">- 1</button>
<button click.delegate="decrement(5)">- 5</button>
<button click.delegate="decrement(100)">- 100</button>
</template>
export class App {
counter = 0;
reset() {
this.counter = 0;
}
increment(by) {
this.counter = this.counter + by;
}
decrement(by) {
this.counter = this.counter - by;
}
}
<!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