3.0.0 • Published 1 year ago

ngx-country-picker v3.0.0

Weekly downloads
494
License
MIT
Repository
github
Last release
1 year ago

ngx-country-picker

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

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:

$ npm install ngx-country-picker --save

or with Yarn :

$ yarn add ngx-country-picker

Consuming the Country Picker

Add the CountryPickerModule to your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { CountryPickerModule } from 'ngx-country-picker';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    // Import here
    CountryPickerModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

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

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

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

export class YourComponent {

  public countries: ICountry[] = [];

  ...

  constructor(protected countryPicker: CountryPickerService) {

  }

  ...

  public ngOnInit(): void {
    this.countryPicker.getCountries()
      .subscribe((countries: ICountry[]) => this.countries = countries);
  }

  ...
}

Development

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

$ yarn run build

To lint all *.ts files:

$ yarn run lint

License

MIT © Guillaume RODRIGUEZ

3.0.0

1 year ago

2.2.0

4 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.4.0

5 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago