项目作者: guillaume-ro-fr

项目描述 :
This Angular module provides a service and a component to show a country picker with localizable names.
高级语言: TypeScript
项目地址: git://github.com/guillaume-ro-fr/ngx-country-picker.git
创建时间: 2017-11-13T21:37:22Z
项目社区:https://github.com/guillaume-ro-fr/ngx-country-picker

开源协议:MIT License

下载


DEPRECATED : This module is deprecated. Please create your own service with world-countries

ngx-country-picker

Build Status
GitHub Downloads All Releases
npm Downloads All Releases
FOSSA Status
Angular Version

This Angular module provides a service and a component to show a country picker with localizable names, inspired
by Paldom/angular2-countrypicker

Installation

To install this library, run:

  1. $ npm install ngx-country-picker --save

or with Yarn :

  1. $ yarn add ngx-country-picker

Consuming the Country Picker

Add the CountryPickerModule to your Angular AppModule:

  1. import { BrowserModule } from '@angular/platform-browser';
  2. import { NgModule } from '@angular/core';
  3. import { AppComponent } from './app.component';
  4. // Import your library
  5. import { CountryPickerModule } from 'ngx-country-picker';
  6. @NgModule({
  7. declarations: [
  8. AppComponent
  9. ],
  10. imports: [
  11. BrowserModule,
  12. // Import here
  13. CountryPickerModule.forRoot()
  14. ],
  15. providers: [],
  16. bootstrap: [AppComponent]
  17. })
  18. export class AppModule {
  19. }

Once CountryPicker is imported, you can use the component in your Angular application:

  1. <!-- You can now use the CountryPickerComponent in app.component.html -->
  2. <h1>
  3. {{title}}
  4. </h1>
  5. <country-picker [flag]="false" [setValue]="'cca3'" [setName]="'name.common'"
  6. [classes]="['form-control']"></country-picker>

You can also use the CountryPickerService to import the list of countries in your app:

  1. export class YourComponent {
  2. public countries: ICountry[] = [];
  3. ...
  4. constructor(protected countryPicker: CountryPickerService) {
  5. }
  6. ...
  7. public ngOnInit(): void {
  8. this.countryPicker.getCountries()
  9. .subscribe((countries: ICountry[]) => this.countries = countries);
  10. }
  11. ...
  12. }

Development

To generate all *.js, *.d.ts and *.metadata.json files:

  1. $ yarn run build

To lint all *.ts files:

  1. $ yarn run lint

License

MIT © Guillaume RODRIGUEZ