Last active
August 10, 2016 07:11
-
-
Save jsobell/270b55ea511728af7bbf937b8391c2ca to your computer and use it in GitHub Desktop.
Binding to a multiple select box
This file contains 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> | |
<select multiple value.bind="displayStatus"> | |
<option repeat.for='foo of things' value="${foo.key}">${foo.key} | ${foo.value}</option> | |
</select> | |
Current status: ${displayStatus.length} | |
<hr/> | |
<select multiple value.bind="displayStatusObjects"> | |
<option repeat.for='foo of things' model.bind="foo.key">${foo.key} | ${foo.value}</option> | |
</select> | |
Current status: ${displayStatusObjects.length} | |
<pre> | |
${debug} | |
</pre> | |
<select value.bind="selectedLanguage" matcher.bind="languageComparer" change.delegate="switchLanguage()" class="form-control"> | |
<option repeat.for="language of languages" model.bind="language">${language.shortName}</option> | |
</select> | |
Selected = ${selectedLanguage.id} | |
</template> |
This file contains 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 { | |
things = [ | |
{ key:11, value:'AAAA'}, | |
{ key:22, value:'BBBB'}, | |
{ key:33, value:'CCCC'}, | |
{ key:44, value:'DDDD'} | |
] | |
displayStatus = null; | |
displayStatusObjects = null; | |
get debug() { | |
return JSON.stringify(this.displayStatusObjects); | |
} | |
languages = [ | |
{"id":"3c42058e-638a-4b6b-bec5-50052e3a3c41","code":"EN","shortName":"en","name":"English","isDefault":false}, | |
{"id":"227e0905-8601-4ecd-9719-813638310fbd","code":"BG","shortName":"бг","name":"Български","isDefault":true}]; | |
selectedLanguage = {"id":"227e0905-8601-4ecd-9719-813638310fbd","code":"BG","shortName":"бг","name":"Български","isDefault":true}; | |
languageComparer = (langA, langB) => { console.log('comparing',langA.id,'to',langB.id); return langA.id === langB.id }; | |
switchLanguage = () => {}; | |
} | |
This file contains 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"> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
This file contains 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> | |
HI, I'm a basic file! | |
</template> |
This file contains 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 {Origin, protocol} from 'aurelia-metadata'; | |
import {relativeToFile} from 'aurelia-path'; | |
import {TemplateRegistryEntry} from 'aurelia-loader'; | |
import {ViewEngine} from './view-engine'; | |
import {ResourceLoadContext, ViewCompileInstruction} from './instructions'; | |
import {DOM, PLATFORM} from 'aurelia-pal'; | |
@viewStrategy() | |
export class MvcViewStrategy { | |
/** | |
* Creates an instance of TemplateRegistryViewStrategy. | |
* @param moduleId The associated moduleId of the view to be loaded. | |
* @param entry The template registry entry used in loading the view factory. | |
*/ | |
constructor(moduleId: string, entry: TemplateRegistryEntry) { | |
this.moduleId = moduleId; | |
this.entry = entry; | |
} | |
/** | |
* Loads a view factory. | |
* @param viewEngine The view engine to use during the load process. | |
* @param compileInstruction Additional instructions to use during compilation of the view. | |
* @param loadContext The loading context used for loading all resources and dependencies. | |
* @return A promise for the view factory that is produced by this strategy. | |
*/ | |
loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext): Promise<ViewFactory> { | |
let entry = this.entry; | |
if (entry.factoryIsReady) { | |
return Promise.resolve(entry.factory); | |
} | |
compileInstruction.associatedModuleId = this.moduleId; | |
return viewEngine.loadViewFactory(entry, compileInstruction, loadContext); | |
} | |
} |
This file contains 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
console.log('Hello World!'); |
This file contains 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
/* todo: add styles */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment