Skip to content

Instantly share code, notes, and snippets.

@swalters
Last active October 17, 2016 14:09
Show Gist options
  • Save swalters/969d9acb15605f46804f4bbf01590faa to your computer and use it in GitHub Desktop.
Save swalters/969d9acb15605f46804f4bbf01590faa to your computer and use it in GitHub Desktop.
Aurelia Childen not working with inlineView
<template>
<require from='./parentComponent'></require>
<require from='./childComponent'></require>
<p>Should log a count of child components</p>
<parent-component>
<child-component>one</child-component>
</parent-component>
</template>
export class App {
message = 'Aurelia Template';
activate() {
}
attached() {
}
}
import {noView,
customElement} from 'aurelia-framework';
@customElement('child-component')
@noView()
export class ChildComponent {
}
<!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/vegarringdal/vGridGistRunJSPMBundle/v.1.0.7/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/vegarringdal/vGridGistRunJSPMBundle/v.1.0.7/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
import {bindable,
inlineView,
customElement,
children} from 'aurelia-framework';
import {ChildComponent} from './childComponent'
@customElement('parent-component')
@inlineView(`<template><slot></slot></template>`)
export class ParentComponent {
@children('child-component') children:ChildComponent[] = [];
attached(){
console.log('children Count: ' + this.children.length);
}
}
<template>
<slot></slot>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment