19 lines
512 B
TypeScript
19 lines
512 B
TypeScript
import { Pipe, PipeTransform } from '@angular/core';
|
|
import { CountryCode } from 'libphonenumber-js';
|
|
import { PhoneNumberUtil } from '../utils/phone-number.util';
|
|
|
|
@Pipe({ name: 'ucapPhoneNumber' })
|
|
export class PhoneNumberPipe implements PipeTransform {
|
|
public transform(
|
|
value: string,
|
|
country?: CountryCode,
|
|
mask: boolean = false
|
|
): string {
|
|
if (!!value && value.trim().length > 0) {
|
|
return PhoneNumberUtil.format(value, country, mask);
|
|
} else {
|
|
return value;
|
|
}
|
|
}
|
|
}
|