Skip to content

Instantly share code, notes, and snippets.

@jsobell
Created June 6, 2016 01:04
Show Gist options
  • Save jsobell/e3c610dffba56babfc6911d90b969d9a to your computer and use it in GitHub Desktop.
Save jsobell/e3c610dffba56babfc6911d90b969d9a to your computer and use it in GitHub Desktop.
Aurelia RequireJS Gist
<template>
<ul>
<li>
Inspect Div A and Div B in dev tools
and pay attention to their classes.
</li>
<li>
Click all of the "click me" text and observe Div A and Div B classes change.
</li>
</ul>
<pre>
${whatnot}
</pre>
<div repeat.for="item of items"
click.delegate="removeItem(item)">
${item}
</div>
<div ref='what'>
<div class="${items.length ? 'twelve wide column' : 'sixteen wide column'}">
Div A</div>
<div class="${items.length ? 'a b c' : 'd e f'}">
Div B</div>
<div class="${items.length ? 'twelve' : 'sixteen'} wide column">
Div C</div>
</div>
</template>
export class App {
message = 'Hello World!';
items = ['click me', 'click me', 'click me', 'click me'];
what = {};
removeItem(item) {
var index = this.items.indexOf(item);
this.items.splice(index, 1);
console.log('item is removed:', item);
}
get whatnot() {
return this.what.innerHTML;
}
}
<!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