Skip to content

Instantly share code, notes, and snippets.

@zakjan
Created November 23, 2016 05:50
Show Gist options
  • Save zakjan/4b48d91c317374528aa9303ff3547f8a to your computer and use it in GitHub Desktop.
Save zakjan/4b48d91c317374528aa9303ff3547f8a to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<require from="./item"></require>
<h1>${message}</h1>
<ul>
<li repeat.for="item of items">
${item}:
<item item.bind="item" click-handler.bind="itemClicked" title="itemClicked"></item>
<item item.bind="item" click-handler.bind="itemClicked.bind($this)" title="itemClicked.bind($this)"></item>
<item item.bind="item" click-handler.bind="itemClickedBound" title="itemClickedBound"></item>
</li>
</ul>
</template>
export class App {
message = 'Hello World!';
items = [1,2,3,4,5];
itemClickedBound = this.itemClicked.bind(this);
itemClicked(item) {
this.doSomething(item);
}
doSomething(item) {
console.log(item);
}
}
<!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://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
<template>
<button click.trigger="clickHandler(item)">${title}</button>
</template>
import {bindable} from "aurelia-framework";
export class ItemCustomElement {
@bindable item;
@bindable clickHandler;
@bindable title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment