Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Forked from fabioluz/app.html
Created August 10, 2016 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdanyow/9f96ac9d135fb39f4b7c172a23e6859c to your computer and use it in GitHub Desktop.
Save jdanyow/9f96ac9d135fb39f4b7c172a23e6859c to your computer and use it in GitHub Desktop.
<template>
<require from="./language-switcher"></require>
<language-switcher languages.bind="languages" selected-language.bind="selectedLanguage">
</language-switcher>
<br><br>
${selectedLanguage.shortName}
</template>
export class App {
someMessage = 'My message here';
languages = [ { shortName: 'EN', id: 1 }, { shortName: 'PT', id: 2 }];
selectedLanguage = this.languages[1];
}
<!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>
<template>
<select value.bind="selectedLanguage" matcher.bind="languageMatcher">
<option repeat.for="language of languages" model.bind="language">${language.shortName}</option>
</select>
</template>
import {bindable, bindingMode} from 'aurelia-framework';
export class LanguageSwitcher {
@bindable languages;
@bindable({ defaultBindingMode: bindingMode.twoWay }) selectedLanguage;
languageMatcher = (a, b) => {
console.log(a,b);
return a.id === b.id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment