Skip to content

Instantly share code, notes, and snippets.

@thinkOfaNumber
Last active November 1, 2017 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkOfaNumber/c23e654e5052b797dd8e92a524dd095c to your computer and use it in GitHub Desktop.
Save thinkOfaNumber/c23e654e5052b797dd8e92a524dd095c to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<require from="./foo"></require>
<h1>Demo</h1>
<p>App.js has ${userAccountsData.length} accounts</p>
<foo accounts-data.bind="userAccountsData"></foo>
</template>
export class App {
message = 'Hello World!';
userAccountsData = [];
constructor() {
this.userAccountsData = [];
// this represents getting some data from the server after some time
window.setTimeout(() => {
this.userAccountsData = ["1", "2", "3"];
}, 2000);
}
}
<template>
<p>foo has ${accounts.length} accounts</p>
<p>foo has ${accountsData.length} from accountsData</p>
</template>
import { bindable} from 'aurelia-framework';
export class Foo {
@bindable accountsData;
constructor() {
this.accounts = [];
}
attached()
{
this.accounts = this.accountsData;
}
}
<!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