Skip to content

Instantly share code, notes, and snippets.

@pjschreifels
Last active November 21, 2016 21:14
Show Gist options
  • Save pjschreifels/ed41efa5081ed5ba027283e71d38ffe8 to your computer and use it in GitHub Desktop.
Save pjschreifels/ed41efa5081ed5ba027283e71d38ffe8 to your computer and use it in GitHub Desktop.
Aurelia <let> binding example.
<template>
<require from="./value-converter"></require>
<div repeat.for="item of dataSet | filter">
<p>${item.title}</p>
</div>
</template>
export class App {
dataSet = [
{title: 'Title 1', show: false},
{title: 'Title 2', show: false},
{title: 'Title 3', show: false},
{title: 'Title 4', show: false}
];
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body aurelia-app="main">
<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>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-validation');
aurelia.start().then(() => aurelia.setRoot());
}
export class FilterValueConverter {
toView(array) {
return array.filter(data => {
return (data.show || false);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment