Skip to content

Instantly share code, notes, and snippets.

@TylerJPresley
Last active February 16, 2017 21:26
Show Gist options
  • Save TylerJPresley/b9c82751fd6bfa6a6b8d66fc8856b2ff to your computer and use it in GitHub Desktop.
Save TylerJPresley/b9c82751fd6bfa6a6b8d66fc8856b2ff to your computer and use it in GitHub Desktop.
DI inheritance
<template>
<input type="text" value.bind="_filter">
<hr>
<div repeat.for="item of filteredItems">${item.id} - ${item.text}</div>
</template>
import { computedFrom } from 'aurelia-framework';
export class App {
_filter = '';
items = [
{ id: 111, text: 'apple' },
{ id: 221, text: 'peach' },
{ id: 333, text: 'orange' },
{ id: 456, text: 'berry' },
{ id: 578, text: 'melon' }
];
@computedFrom('_filter')
get filteredItems() {
return this.items.filter((i) => i.text.indexOf(this._filter) > -1 || String(i.id).indexOf(this._filter) > -1);
}
}
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment