Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
iso-3166-country-codes-angular
Advanced tools
Readme
Note that this README is for the currently developed version of the library
This project is an ISO 3166 (Country codes) module for AngularJS. It provides:
This library is available with the bower package manager, you can either:
bower install iso-3166-country-codes-angular --save
"iso-3166-country-codes-angular": "1.1.1"
You can have access to country codes information and several utilitary methods.
// Declare the factory as dependency
angular.module('myApp', ["iso-3166-country-codes"])
.controller('MyCtrl', function (ISO3166) {
// Test if a value is a country code
console.log(ISO3166.isCountryCode('FR')); // true
console.log(ISO3166.isCountryCode('FRA')); // false
// Get country name
console.log(ISO3166.getCountryName('FR'));
// FRANCE
// Get several country names at once (ignores invalid codes)
console.log(ISO3166.getCountryNames(['DE', 'FR', 'invalid']));
// {
// 'DE': 'Germany',
// 'FR': 'France'
// }
// Get country name, manipulated by String methods.
console.log(ISO3166.getCountryName('FR', 'toLowerCase'));
// france
// Get several country names at once (ignores invalid codes)
console.log(ISO3166.getCountryNames(['DE', 'FR', 'invalid'], 'toLowerCase'));
// {
// 'DE': 'germany',
// 'FR': 'france'
// }
// Get country code by country name
console.log(ISO3166.getCountryCode('France'));
// FR
// Get country code by country name, manipulated by String methods.
console.log(ISO3166.getCountryCode('France'), 'toLowerCase');
// fr
// Direct access to the data
console.log(ISO3166.codeToCountry);
// {
// 'FR': 'France',
// ...
// }
console.log(ISO3166.countryToCode);
// {
// 'France': 'FR'
// ...
// }
console.log(ISO3166.countryCodes);
// ['AF', 'AX', 'AL', ... ]
});
If you get country codes from your REST server, you can print their standard names with the provided filter:
<!-- if countryCode is 'FR', will print 'France' -->
<p>{{countryCode | isoCountry }}</p>
On the other hand, if you get country names from your REST server, you can print their ISO codes:
<!-- if countryName is 'France', will print 'FR' -->
<p>{{countryName | isoCountryCode }}</p>
If you want users to enter country codes, you can validate it like so (it fits in Angular validation process):
<form name="form" novalidate>
<input type="text" name="countryField" country-code />
<span ng-show="form.countryField.$error.countrycode">This must be a country code!</span>
</form>
You can use Github's issues to submit feature requests and bug reports.
This project gladly accepts contributions. However, you must agree to give your work explicitely to public domain. To do so, just put this statement in the pull request definition:
I dedicate any and all copyright interest in this software to the
public domain. I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors. I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
This software is given to the public domain. For more information, see the UNLICENSE
file.
FAQs
An AngularJS module to work with Country Codes
The npm package iso-3166-country-codes-angular receives a total of 274 weekly downloads. As such, iso-3166-country-codes-angular popularity was classified as not popular.
We found that iso-3166-country-codes-angular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.