Skip to content

Instantly share code, notes, and snippets.

@ZoolWay
Last active June 23, 2017 11:27
Show Gist options
  • Save ZoolWay/6704584ca04199a143e349a6e91a5e5c to your computer and use it in GitHub Desktop.
Save ZoolWay/6704584ca04199a143e349a6e91a5e5c to your computer and use it in GitHub Desktop.
Aurelia Binding ES6 Map
<template>
<h1>Aurelia Debounce</h1>
<div ref="areaContainer">
<h2>Textbox:</h2>
<div style="border:1px solid blue; padding: 1em; margin: 1em;">
<input value.bind="myMap['masterkey']" placeholder="type here" />
</div>
<div style="border:1px solid black; padding: 1em; margin: 1em;">
output: ${myMap['masterkey']}
</div>
<div style="border:1px solid black; padding: 1em; margin: 1em;">
output: ${myMap.get('masterkey')}
</div>
<button click.delegate="changeMaster()">Change Master Key</button>
</div>
</template>
//import { observable } from 'aurelia-framework'
export class App {
myText = '';
myMap = new Map();
constructor() {
this.myMap.set('masterkey', '-42-');
this.myMap.set('housekey', 'peach');
}
changeMaster() {
let current = this.myMap.get('masterkey');
if (current === '-42-') {
this.myMap.set('masterkey', '+84+');
} else {
this.myMap.set('masterkey', '-42-');
}
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<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>
export function configure(aurelia) {
aurelia.use.standardConfiguration();
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment