Create a gist now

Instantly share code, notes, and snippets.

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