Skip to content

Instantly share code, notes, and snippets.

@blkbltjns
Forked from fabioluz/app.html
Last active July 24, 2017 16:46
Show Gist options
  • Save blkbltjns/854f38ddfa0abac901ded323b2f3dae7 to your computer and use it in GitHub Desktop.
Save blkbltjns/854f38ddfa0abac901ded323b2f3dae7 to your computer and use it in GitHub Desktop.
<template>
<div id="container">
<div repeat.for="item of items">
<compose view-model="${item.viewModel}" model.bind="item.data"></compose>
</div>
</div>
<div style='margin-top: 20px'>
<div repeat.for="log of logs">
${log}
</div>
</div>
<button click.delegate="click()">add</button>
</template>
import {inject, TaskQueue} from 'aurelia-framework';
@inject(TaskQueue)
export class App {
constructor(taskQueue) {
this.items = [];
this._taskQueue = taskQueue;
this.logs = [];
}
click() {
this.items.push({
viewModel: 'child',
data: "C"
});
this.logs.push('Height after click: ' + this._container.clientHeight);
}
bind() {
this.items.push({
viewModel: 'child',
data: "A"
});
this.items.push({
viewModel: 'child',
data: "B"
});
}
attached() {
this._container = document.getElementById('container');
this.logs.push('Height after adding items: ' + this._container.clientHeight);
this._taskQueue.queueMicroTask(() => {
this.logs.push('Height after queued microtask: ' + this._container.clientHeight);
});
setTimeout(() => {
this.logs.push('Height after waiting a second: ' + this._container.clientHeight);
}, 1000);
}
}
<template>
${data}
</template>
export class Child {
activate(data) {
this.data = data;
}
}
<!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