Created
December 7, 2016 03:13
-
-
Save plwalters/0e39d35c2185e8d396e870222379ba97 to your computer and use it in GitHub Desktop.
aurelia:complex type, clear input
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> | |
<input type="text" value.bind="address.line1" /> | |
</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 {bindable} from 'aurelia-framework'; | |
export class Address { | |
@bindable address; | |
} |
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> | |
<require from="./address"></require> | |
<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> | |
<input type="text" value.bind="val.address.line1" /> | |
<hr /> | |
<select value.bind="val2" if.bind="opts2 && !val2"> | |
<option repeat.for="opt of opts2" model.bind="opt">${opt.firstName}</option> | |
</select> | |
<div if.bind="!opts2 || val2"> | |
<span>${val2.firstName}</span> | |
<button click.delegate="clearVal2()" if.bind="val2">Clear</button> | |
</div> | |
<button click.delegate="getOpts2()">Get</button> | |
<div>${val2.blah}</div> | |
<!--<input type="text" value.bind="val2.blah"/>--> | |
<hr /> | |
<select value.bind="val3" if.bind="opts3 && !val3"> | |
<option repeat.for="opt of opts3" model.bind="opt">${opt.firstName}</option> | |
</select> | |
<div if.bind="!opts3 || val3"> | |
<span>${val3.firstName}</span> | |
<button click.delegate="clearVal3()" if.bind="val3">Clear</button> | |
</div> | |
<button click.delegate="getOpts3()">Get</button> | |
<address address.bind="val3.address"></div> | |
<!--<input type="text" value.bind="val2.blah"/>--> | |
</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
export class App { | |
opts; | |
opts2; | |
opts3; | |
val; | |
val2; | |
val3; | |
getOpts(){ | |
this.opts = [ | |
undefined, | |
{ | |
blah: 1, | |
firstName: 'foo', | |
address: { | |
line1: '123 Main St.' | |
} | |
}, | |
{ | |
blah: 2, | |
firstName: 'bar', | |
address: { | |
line1: '456 Other Wy.' | |
} | |
} | |
]; | |
} | |
getOpts2(){ | |
this.opts2 = [ | |
undefined, | |
{ | |
blah: 1, | |
firstName: 'foo', | |
address: { | |
line1: '123 Main St.' | |
} | |
}, | |
{ | |
blah: 2, | |
firstName: 'bar', | |
address: { | |
line1: '456 Other Wy.' | |
} | |
} | |
]; | |
} | |
getOpts3(){ | |
this.opts3 = [ | |
undefined, | |
{ | |
blah: 1, | |
firstName: 'foo', | |
address: { | |
line1: '123 Main St.' | |
} | |
}, | |
{ | |
blah: 2, | |
firstName: 'bar', | |
address: { | |
line1: '456 Other Wy.' | |
} | |
} | |
]; | |
} | |
clearVal(){ | |
this.val = null; | |
} | |
clearVal2(){ | |
this.val2 = null; | |
} | |
clearVal3(){ | |
this.val3 = null; | |
} | |
} |
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