Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Country picker view-model
import {HttpClient} from 'aurelia-fetch-client';
import {bindable} from 'aurelia-framework';
export class CountryPicker{
@bindable country;
constructor(){
this.selected = {"name" : 'Australia', "code" : 'AU'};
this.templateUrl = 'templates/country-template.html';
}
getCountries(countryName){
let client = new HttpClient();
return client.fetch('countries.json')
.then(response => response.json())
.then(countries => {
if(!countryName) return countries;
return countries.filter(c => c.name.toUpperCase().indexOf(countryName.toUpperCase() !== -1));
});
}
countryChanged(evt){
if(!evt.target) return;
this.country = evt.target.value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.