Module: Country

Country

Country service utility for cross-component usage.

Author:
  • Marco Lehmann <marco.lehmann (at) kiwigrid.com>
Source:

Classes

CountryUtils

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 countries
Examples
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};
            });

    });