-
-
Save AshleyGrant/e4b594eaa452b47d9b3984e7f9b04109 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<select value.bind="val" if.bind="opts && !val"> | |
<option repeat.for="opt of opts" model.bind="opt">${opt.firstName}</option> | |
</select> | |
<button click.delegate="getOpts()">Get</button> | |
</div> | |
<div if.bind="!opts || person"> | |
<span>First Name: ${person.firstName}</span> | |
<button click.delegate="resetForm()" if.bind="val">Clear Selection</button> | |
</div> | |
Address: <input type="text" value.bind="person.address.line1" /> | |
<hr /> | |
val | |
<pre><code> | |
${toJSON(val)} | |
</code></pre> | |
person | |
<pre><code> | |
${toJSON(person)} | |
</code></pre> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {observable} from 'aurelia-framework'; | |
export class App { | |
@observable val = null; | |
person = {}; | |
getOpts(){ | |
this.opts = [ | |
null, | |
{ | |
blah: 1, | |
firstName: 'foo', | |
address: { | |
line1: '123 Main St.' | |
} | |
}, | |
{ | |
blah: 2, | |
firstName: 'bar', | |
address: { | |
line1: '456 Other Wy.' | |
} | |
} | |
]; | |
} | |
valChanged() { | |
this.person = this.val; | |
console.log("set person"); | |
} | |
resetForm(){ | |
this.val = null; | |
console.log("reset val"); | |
} | |
toJSON(value) { | |
if(!(value === false) && !value) { | |
return ''; | |
} | |
return JSON.stringify(value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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