npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-countries-phone

v1.0.2

Published

An angular component that has an country dial code selection and mask phone number input.

Downloads

2

Readme

Custom Countries Dial Phone Codes

An angular component that has an country dial code selection and mask phone number input.

Installation

Use npm to install the package

$ npm i ng-countries-phone --save 

Import

You must add into your module imports the CountryPhoneModule in order to use component.

import { CountryPhoneModule } from 'ng-countries-phone';

@NgModule({
 // ...
 imports: [
   // ...
   CountryPhoneModule
 ]
})

You must add this configuration into your project's angular.json following this path angularjson.projects.your-project-name.architect.build.options. Then,you can import package's assets into your project assets. Because in the package assets there is a country json file.

 "assets": [
            "src/favicon.ico",
            "src/assets",
            {
              "glob": "**/*",
              "input": "./node_modules/ng-countries-phone/assets",
              "output": "./assets/"
            }

How to use

You can use component like below.

  • Your parent form.
testForm: FormGroup;

ngOnInit(): void {
   this.createForm();
}

createForm() {
  this.testForm = this.fb.group({
    code: ['',Validators.required],
    phone: ['', [Validators.required, Validators.minLength(8), Validators.maxLength(40)]],
  });
}

get codeControl() { return this.testForm.get('code'); }
get phoneControl() { return this.testForm.get('phone'); }

onSubmit(){
  const formData=this.testForm.getRawValue();
  //.. Do some busines..
}
  • Using app-phone in parent form.
<form [formGroup]="testForm" (submit)="onSubmit()">
    <!-- you can use inside your form. But you have to bind your testForm with parentForm attribute-->
    <app-phone
     [parentForm]="testForm" 
     [codeFormControlName]="'code'" 
     [phoneFormControlName]="'phone'"
     [codeControl]="codeControl"
     [phoneControl]="phoneControl"
     [defaultSelectedCountry]="'+90'">
     </app-phone>
</form>

alt text

Attributes

You can customize component with your own css classes and you can give some configration. There are some details in the below tables.

| Attribute | Description | | :--- | :----: | | codeClass | class of country selection. It has boostrap ".form-select" class default. But, you can set your own class.| | phoneClass | class of phone input. It has boostrap ".form-control" class default. But, you can set your own class.| | formGroupClass | class of parent div of country selection and phone input. It has boostrap ".form-group" class default. But, you can set your own class.| | codeControl | FormControl of parentForm for country selection.| | phoneControl | FormControl of parentForm for phone input.| | parentForm | Parent form.| | phoneLabelText | Phone input label. It has default "Phone Number" value.| | codeLabelText | Country selection label. It has default "Country Code" value.| | codeFormControlName | FormControlName of parent form for country selection code.| | phoneFormControlName | FormControlName of parent form for phone input.| | codeValidationMessage | Custom validation message for country selection.| | defaultSelectedCountry | Default selected country code is "+90" Turkey. You can set your own.| | phoneValidationMessage | Custom validation message for phone input.|

Contributing And Issues

  • Before adding any new feature or a fix make sure to open an issue first!
  • Make sure you have angular-cli installed globally.
$ npm install -g angular-cli
  • Clone the project, and install dependencies.
$ git clone https://github.com/ismailkasan/countries-phone.git
$ npm install
  • Create a new branch
$ git checkout -b feat/someFeature
  • Make sure everything is running properly
  • Commit & push, and make a pull request!