Skip to content

Instantly share code, notes, and snippets.

@plwalters
Forked from peinearydevelopment/address.html
Last active December 7, 2016 03:19
Show Gist options
  • Save plwalters/7b9d230f7d3c6dc8c13cefdd7be50c7f to your computer and use it in GitHub Desktop.
Save plwalters/7b9d230f7d3c6dc8c13cefdd7be50c7f to your computer and use it in GitHub Desktop.
aurelia:complex type, clear input
<template>
<select value.bind="val" if.bind="opts && !val">
<option repeat.for="opt of opts" model.bind="opt">${opt.firstName}</option>
</select>
<div if.bind="!opts || val">
<span>${val.firstName}</span>
<button click.delegate="clearVal()" if.bind="val">Clear</button>
</div>
<button click.delegate="getOpts()">Get</button>
<template with.bind="val.address">
<input type="text" value.bind="line1" />
</template>
</template>
export class App {
opts;
val;
getOpts(){
this.opts = [
undefined,
{
blah: 1,
firstName: 'foo',
address: {
line1: '123 Main St.'
}
},
{
blah: 2,
firstName: 'bar',
address: {
line1: '456 Other Wy.'
}
}
];
}
clearVal(){
this.val = null;
}
}
class Option {
blah;
firstName = '';
address = {
line1: ''
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<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()
.developmentLogging();
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment