Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
international-phone-numbers
Advanced tools
Readme
This is a simple library that provides component and service for dealing with capturing and validating international phone numbers. It allows you to create a phone number field with country flag, country name and country postal code dropdown.
npm install international-phone-numbers
PhoneNumbersModule
and PhoneNumbersService
in your app's main module app.module.ts
,PhoneNumbersModule
under imports and PhoneNumbersService
under providers, e.g.:// other imports
// ...
import { PhoneNumbersModule, PhoneNumbersService } from 'phone-numbers';
// ...
@NgModule({
imports: [
// other imports
// ...
PhoneNumbersModule,
// ...
],
providers: [
PhoneNumbersService
]
})
Place phone numbers component selector in a template, for example in AppComponent
or any other component you would want to use the selector:
import { Component } from "@angular/core";
@Component({
selector: 'my-app',
template: `
<phone-numbers></phone-numbers>
<router-outlet></router-outlet>
`
})
export class AppComponent {}
Also import PhoneNumbersService in the same component where you are accessing the phone numbers selector in order to get formatted phone number e.g.:
import { Component } from "@angular/core";
import { PhoneNumbersService } from 'phone-numbers';
@Component({
selector: 'my-app',
template: `
<phone-numbers></phone-numbers>
<router-outlet></router-outlet>
`
})
export class AppComponent {}
PhoneNumbersService
stores selected phone number, selected postal code and selected country, therefore those values can be retrieved from the service on changing values from selector.
Secondly, PhoneNumbersService
validates the entered mobile number is valid.
private selectedMobileNumber: string;
private selectedPostalCode: string;
private selectedCountry: string;
private isMobileNumberValid: boolean;
constructor(private phoneNumbersService: PhoneNumbersService, ...) {
// ...
}
// getting selected phone number
this.selectedMobileNumber = this.phoneNumbersService.selectedMobileNumber;
// getting selected postal code
this.selectedPostalCode = this.phoneNumbersService.selectedPostalCode;
// getting selected country
this.selectedCountry = this.phoneNumbersService.selectedCountry;
// validating phone number
this.isMobileNumberValid = this.phoneNumbersService.isMobileNumberValid();
Please leave your feedback if you have noticed any issue or have a feature request.
The repository code is open-sourced software licensed under the MIT license.
FAQs
Angular 7 international phone numbers module
The npm package international-phone-numbers receives a total of 0 weekly downloads. As such, international-phone-numbers popularity was classified as not popular.
We found that international-phone-numbers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.