Skip to content

Instantly share code, notes, and snippets.

@zakjan
Last active November 27, 2016 12:32
Show Gist options
  • Save zakjan/8f1021e1b276a2c7ecab8722a0799c49 to your computer and use it in GitHub Desktop.
Save zakjan/8f1021e1b276a2c7ecab8722a0799c49 to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<h1>${message}</h1>
<ul>
<li repeat.for="item of items">
<input type="checkbox" model.bind="item" checked.bind="selectedItems" matcher.bind="matcher">
<input type="checkbox" model.bind="item" checked.bind="selectedItems" matcher.bind="matcher.bind($this)">
<input type="checkbox" model.bind="item" checked.bind="selectedItems" matcher.bind="matcher.bind(this2)">
${item.type} ${item.id}
</li>
</ul>
<p>Selected: ${selectedItemsString}</p>
</template>
class ItemUtils {
itemsAreEqual(item1, item2) {
return item1 && item2 && item1.type === item2.type && item1.id === item2.id;
}
}
export class App {
message = 'Hello World!';
items = [{type: "car", id: 1}, {type: "car", id: 2}, {type: "car", id: 3}, {type: "truck", id: 1}, {type: "truck", id: 2}];
selectedItems = [{type: "car", id: 1}];
itemUtils = new ItemUtils();
matcherBound = this.matcher.bind(this);
matcher(item1, item2) {
console.log(this);
return this && this.itemUtils && this.itemUtils.itemsAreEqual(item1, item2);
}
get selectedItemsString() {
return JSON.stringify(this.selectedItems);
}
get this2() {
return this;
}
}
<!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