Skip to content

Instantly share code, notes, and snippets.

@mbroadst
Forked from reneolivo/app.html
Last active September 7, 2016 23:40
Show Gist options
  • Save mbroadst/a80075df458d01d334e37a22b3108d45 to your computer and use it in GitHub Desktop.
Save mbroadst/a80075df458d01d334e37a22b3108d45 to your computer and use it in GitHub Desktop.
Aurelia Templating Child/Children Bug
<template>
<require from="my-list"></require>
<require from="my-list-element"></require>
<my-list>
<my-list-element>one</my-list-element>
<my-list-element>two</my-list-element>
<my-list-element>three</my-list-element>
</my-list>
</template>
export class App {
}
<!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();
aurelia.start().then(() => aurelia.setRoot());
}
import {inject} from 'aurelia-dependency-injection';
import {
bindable,
customElement,
noView,
processContent,
ViewCompiler
} from 'aurelia-templating';
@noView
@processContent(false)
@customElement('my-list-element')
@inject(Element, ViewCompiler)
export class MyListElement {
constructor(element, viewCompiler) {
this.viewFactory =
viewCompiler.compile(`<template>${element.innerHTML}</template>`);
element.innerHTML = '';
}
}
<template>
<slot></slot>
</template>
import {children} from 'aurelia-templating';
export class MyList {
@children('my-list-element') rows = [];
attached() {
console.log('children: ', this.rows);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment