Created
September 13, 2016 05:34
-
-
Save Thanood/22b6c2c0187883ac7a2c96d9fc2be81e to your computer and use it in GitHub Desktop.
Aurelia - Materialize Select issue #270
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> | |
<form role="form"> | |
<div class="col s12 m6 push-m3 l4 push-l4"> | |
<div class="row"> | |
<div class="input-field col s12"> | |
<select md-select value.two-way="residingAddress.country"> | |
<option value="" disabled>Select Country of residence..</option> | |
<option repeat.for="country of countryList" value.bind="country.code">${country.name}</option> | |
</select> | |
<label class="active" for="country">Country</label> | |
</div> | |
</div> | |
<div class="row" show.bind="filteredStateList!=null && filteredStateList.length>0"> | |
<div class="input-field col s12"> | |
<select md-select md-select.ref="select" value.two-way="residingAddress.state" > | |
<option value="" disabled>Select State of residence</option> | |
<option repeat.for="state of filteredStateList" value.bind="state.short">${state.name}</option> | |
</select> | |
<label class="active" for="state">State</label> | |
</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, BindingEngine, LogManager} from 'aurelia-framework'; | |
@inject(BindingEngine) | |
export class App { | |
countryList = [ | |
{ code: 'de', name: 'Germany' }, | |
{ code: 'sk', name: 'Sweden' }, | |
{ code: 'us', name: 'United States' } | |
]; | |
stateList = [ | |
{ countryCode: 'de', name: 'Hamburg', short: 'hh' }, | |
{ countryCode: 'de', name: 'Berlin', short: 'ber' }, | |
{ countryCode: 'de', name: 'Bremen', short: 'hb' }, | |
{ countryCode: 'sk', name: 'Stockholm', short: 'st' }, | |
{ countryCode: 'sk', name: 'Södermanlands', short: 'sl' }, | |
{ countryCode: 'sk', name: 'Östergötlands', short: 'ogl' }, | |
{ countryCode: 'us', name: 'Washington', short: 'wa' }, | |
{ countryCode: 'us', name: 'Florida', short: 'fl' }, | |
{ countryCode: 'us', name: 'Texas', short: 'tx' } | |
]; | |
residingAddress = { | |
country: '', | |
state: '' | |
} | |
constructor(bindingEngine) { | |
this.logger = LogManager.getLogger('ProfileSetupAddress'); | |
//this.filterStatesForSelectedCountry(); | |
let subscription = bindingEngine.propertyObserver(this.residingAddress, 'country') | |
.subscribe(() => this.filterStatesForSelectedCountry()); | |
} | |
attached() { | |
this.filterStatesForSelectedCountry(); | |
} | |
filterStatesForSelectedCountry() { | |
let country = this.residingAddress.country; | |
if (country != undefined && country != null) { | |
this.filteredStateList = this.stateList.filter((stateEntry) => { | |
return stateEntry.countryCode === country | |
}); | |
} | |
this.logger.debug('filterStatesForSelectedCountry called ' + country + ' ;' + JSON.stringify(this.filteredStateList)); | |
this.select.refresh(); | |
} | |
} |
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> | |
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script> | |
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-materialize-bundles/0.8.1/config2.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
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
/******************************************************************************* | |
* The following two lines enable async/await without using babel's | |
* "runtime" transformer. Uncomment the lines if you intend to use async/await. | |
* | |
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2 | |
*/ | |
//import regeneratorRuntime from 'babel-runtime/regenerator'; | |
//window.regeneratorRuntime = regeneratorRuntime; | |
/******************************************************************************/ | |
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.plugin('aurelia-materialize-bridge', bridge => bridge.useAll() ); | |
aurelia.start().then(a => a.setRoot()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment