Skip to content

Instantly share code, notes, and snippets.

@AshleyGrant
Forked from Baudin999/app.html
Last active September 22, 2017 10:41
Show Gist options
  • Save AshleyGrant/1b304bb0c6dc98b23f4a3994acc280e4 to your computer and use it in GitHub Desktop.
Save AshleyGrant/1b304bb0c6dc98b23f4a3994acc280e4 to your computer and use it in GitHub Desktop.
Aurelia Compose Containerless Gist
<template>
<require from="container"></require>
<ck-container>
<compose repeat.for="item of items"
view="${item.view}.html"
view-model="${item.view}"
model.bind="item.model"
></compose>
</ck-container>
</template>
export class App {
constructor() {
this.items = [
{ view:"test" },
{ view:"test", model: { value: "some value" } }
];
}
}
<template>
<h1>My container element</h1>
<div>
<slot></slot>
</div>
</template>
import {containerless,customElement} from 'aurelia-framework';
@containerless
@customElement('ck-container')
export class Container {
constructor() {
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
compose {
outline: 3px solid blue;
}
</style>
</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>
<template>
<div>${message}</div>
</template>
export class Test {
constructor(message) {
this.message = "hello world";
}
activate(model) {
if (model) {
this.message = model.value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment