Country service utility for cross-component usage.
- Copyright:
- Kiwigrid GmbH 2014-2016
- Source:
Classes
Methods
-
<inner> getCountryList(currentLocale, accessor) → {Array}
-
Returns the country list for a given locale in the form of {key: 'DE', 'value': 'Germany'}.
Locales only match from specific > general > fallback e.g. 'de_AT' > 'de' > 'en'.
Accessor provides the possibility to reformat the return value on per usage basis. The accessor is optional.
Parameters:
Name Type Description currentLocale
string can be either in short ('en') or long ('en_US') format. accessor
function a function to format the output - Source:
Returns:
Array all countriesExamples
angular.module('exampleApp', ['keta.utils.Country']) .controller('ExampleController', function($scope, ketaCountryUtils) { $scope.currentLocale = 'en_GB'; // countries as array of objects {key: ..., value: ...} $scope.countries = ketaCountryUtils.getCountryList($scope.currentLocale); });
angular.module('exampleApp', ['keta.utils.Country']) .controller('ExampleController', function($scope, ketaCountryUtils) { $scope.currentLocale = 'en_GB'; // countries as array of objects {value: ..., name: ...} $scope.countries = ketaCountryUtils.getCountryList($scope.currentLocale, function(countryName, countryCode) { return {value: countryCode, name: countryName}; }); });