Skip to content

Instantly share code, notes, and snippets.

@fabioluz
Last active August 10, 2016 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fabioluz/bcd7841ed21616136d5b6ab259a9d9c2 to your computer and use it in GitHub Desktop.
Save fabioluz/bcd7841ed21616136d5b6ab259a9d9c2 to your computer and use it in GitHub Desktop.
<template>
<require from="./language-switcher"></require>
<language-switcher languages.bind="languages" selected-language.two-way="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>
<form role="language" class="navbar-form navbar-left m-t-1">
<div class="input-group">
<select value.bind="selectedLanguage" change.delegate="switchLanguage()" matcher.bind="languageMatcher" class="form-control">
<option repeat.for="language of languages" model.bind="language">${language.shortName}</option>
</select>
</div>
</form>
</template>
import {inject, customElement, bindable} from 'aurelia-framework';
// import {I18N} from 'aurelia-i18n';
import {Router} from 'aurelia-router';
// import {HubFactory} from 'service';
// import {hub} from 'enums';
@customElement('language-switcher')
@inject(Element, Router)
export class LanguageSwitcher {
languageMatcher = (a, b) => {console.log(a,b); a.id === b.id;}
@bindable languages;
@bindable selectedLanguage;
constructor(element, router) {
this.element = element;
// this.i18n = i18n;
// this.router = router;
// this.usmHub = hubFactory.getHub(hub.usersSessionManagementHub);
}
switchLanguage() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment