Last active
March 14, 2017 14:56
-
-
Save fabioluz/45617c25421eac37be599595d7fda593 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> | |
<require from="./element"></require> | |
<element></element> | |
</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 { | |
message = 'Hello World!'; | |
} |
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='input & debounce' focus.bind='hasFocus'> | |
<div if.bind='results.length'> | |
${results.length} | |
<div repeat.for='result of results' click.delegate='selectOption(result)'> | |
${result} | |
</div> | |
</div> | |
</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 { | |
inject, | |
customElement, | |
containerless, | |
bindable, | |
bindingMode, | |
observable | |
} from 'aurelia-framework'; | |
@customElement('element') | |
@containerless() | |
export class Autosearch { | |
@observable input; | |
constructor() { | |
this.results = []; // input focus with a delay before blur. | |
this.model = { | |
options: ['Foobar','Barfoo','HelloWorld'], | |
selected: null | |
} | |
} | |
attached() { | |
this.input = this.model.selected || ''; | |
} | |
inputChanged(newValue) { | |
if (newValue === this.model.selected) { | |
return; | |
} | |
let pattern = newValue.toLowerCase(); | |
this.results = this.model.options.filter(x => | |
x.toLowerCase().indexOf(pattern) > 0); | |
} | |
selectOption(value) { | |
this.model.selected = value; | |
this.input = value; | |
this.results = []; | |
//setArray(this.results, []); // FIXME Necessary to prevent a crash in aurelia templating. No idea why. | |
} | |
} |
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> | |
<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