Skip to content

Instantly share code, notes, and snippets.

@dagtveit
Created September 15, 2019 19:33
Show Gist options
  • Save dagtveit/248d336c1493f26da4fef30719fbd6cb to your computer and use it in GitHub Desktop.
Save dagtveit/248d336c1493f26da4fef30719fbd6cb to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<div aurelia-app="src/configure">
Loading...
</div>
<script src="https://rawgit.com/aurelia-ui-toolkits/demo-materialize/gh-pages/jspm_packages/system.js"></script>
<script src="https://rawgit.com/aurelia-ui-toolkits/demo-materialize/gh-pages/jspm.config.js"></script>
<script>
System.import("aurelia-bootstrapper");
</script>
</body>
</html>
<template>
<div>
You picked: ${value}
<md-lookup value.bind="value" options-function.bind="optionsFunction" label="pick an option"></md-lookup>
</div>
</template>
import { observable } from "aurelia-binding";
import { ILookupOptionsFunctionParameter } from "aurelia-materialize-bridge";
export class App {
companies = ["Microsoft", "Google", "Apple"];
value: string;
optionsFunction(p: ILookupOptionsFunctionParameter<string>): Promise<string[]> {
if (p.value) {
return Promise.resolve([p.value]);
}
else {
return this.searchCompanies(p.filter);
}
}
searchCompanies(filter: string): Promise<string[]> {
return new Promise<any[]>((resolve, reject) => {
setTimeout(() => resolve(this.companies.filter(x => x.includes(filter))), 1000);
});
}
setValue() {
this.value = this.companies[2];
}
}
export async function configure(aurelia) {
await aurelia.loader.loadModule("materialize-css");
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin("aurelia-materialize-bridge", bridge => bridge.useAll())
.plugin("aurelia-validation")
.globalResources("src/shared/logger");
await aurelia.start();
aurelia.setRoot("src/app");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment