Skip to content

Instantly share code, notes, and snippets.

@swalters
Forked from ZoolWay/app.html
Created October 17, 2016 13:16
Show Gist options
  • Save swalters/084df819ba204c3d5d6448674d8767b5 to your computer and use it in GitHub Desktop.
Save swalters/084df819ba204c3d5d6448674d8767b5 to your computer and use it in GitHub Desktop.
Aurelia Childen not working with noView
<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>
<child-component>two</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/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>
import {bindable,
noView,
customElement,
children} from 'aurelia-framework';
import {ChildComponent} from './childComponent'
@customElement('parent-component')
@noView()
export class ParentComponent {
@children('child-component') children:ChildComponent[] = [];
attached(){
console.log('children Count: ' + this.children.length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment