Skip to content

Instantly share code, notes, and snippets.

@AStoker
Last active July 13, 2017 18:04
Show Gist options
  • Save AStoker/39b571d960bc9d8a0e38bd4688a3a0d4 to your computer and use it in GitHub Desktop.
Save AStoker/39b571d960bc9d8a0e38bd4688a3a0d4 to your computer and use it in GitHub Desktop.
Replaceable list repeaters
<template>
<require from="CustomElement1"></require>
Hello world
<br />
<custom-element1 items.bind="items"></custom-element1>
</template>
export class App {
items = [];
constructor () {
for (let i = 0; i < 5; i++) {
this.items.push({
id: i,
text: `Item: ${i}`
});
}
}
}
<template>
<require from="CustomElement2"></require>
<label>Custom Element 1</label>
<br />
<custom-element2 items.bind="items2">
<template replace-part="item">
<li repeat.for="item of items">
<label>${item.text}</label>
</li>
</template>
</custom-element2>
</template>
import {inject, bindable, BindingEngine} from 'aurelia-framework';
@inject(BindingEngine)
export class CustomElement1 {
@bindable items;
constructor(bindingEngine) {
this.items2 = [];
}
bind() {
this.items2 = this.items;
}
}
<template>
<label>Custom Element 2</label>
<ul>
<li replaceable part="item" repeat.for="item of items">
<label>${item.text}</label>
</li>
</ul>
</template>
import {bindable} from 'aurelia-framework';
export class CustomElement2 {
@bindable items;
}
<!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