International phone prefix library for Angular
npm install ng4-intl-phonets
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MyTestApp } from './my-test-app';
import { InternationalPhoneModule } from 'ng4-intl-phone';
@NgModule({
imports: [ BrowserModule, InternationalPhoneModule ],
declarations: [ MyTestApp ],
bootstrap: [ MyTestApp ]
})
export class MyTestAppModule {}
`
##Testing in localhost
- npm install ./relative/path/to/lib after npm run build to test locally in another app
Usage
Use one of the following two options.
$3
In this option the ngModel binding is used.
`html
{{title}}
`
$3
In this option the value accessor of reactive forms is used.
To use reactive forms define the application class as follows:
`ts
export class MyTestApp implements OnInit {
private myForm: FormGroup;
constructor(private formBuilder: FormBuilder) { }
ngOnInit() {
this.myForm = this.formBuilder.group({
myPhone: ['', Validators.required]
// other controls are here...
});
}
}
`
Add the following snippet inside your template:
`html
``