• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mpalourdio / intl-tel-input-ng / 8323147394

18 Mar 2024 08:04AM CUT coverage: 100.0%. Remained the same
8323147394

Pull #51

github

mpalourdio
chore: Go back to isValidNumber vs isValidNumberPrecise. Fixes #50
Pull Request #51: chore: Go back to isValidNumber vs isValidNumberPrecise. Fixes #50

2 of 2 branches covered (100.0%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

18 of 18 relevant lines covered (100.0%)

8.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/lib/components/intl-tel-input.component.ts
1
/*
2
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
4
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
5
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
6
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
7
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
 */
9

10
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
11
import { ControlContainer, NgForm } from '@angular/forms';
12
import intlTelInput from 'intl-tel-input';
13
import { CountryData, IntlTelInputOptions } from '../model/intl-tel-input-options';
14

15
@Component({
16
    selector: 'intl-tel-input',
17
    templateUrl: './intl-tel-input.component.html',
18
    styleUrls: ['./intl-tel-input.component.scss'],
19
    viewProviders: [{ provide: ControlContainer, useExisting: NgForm }]
20
})
21
export class IntlTelInputComponent implements AfterViewInit {
1✔
22

23
    @Input() cssClass!: string;
24
    @Input() E164PhoneNumber!: string | null;
25
    @Input() label!: string;
26
    @Input() labelCssClass!: string;
27
    @Input() name = 'intl-tel-input-name';
13✔
28
    @Input() options: IntlTelInputOptions = {};
13✔
29
    @Input() required!: boolean;
30
    @Output() private E164PhoneNumberChange = new EventEmitter<string | null>();
13✔
31
    @ViewChild('intlTelInput') private _inputElement!: ElementRef;
32
    private _phoneNumber!: string;
33
    private _intlTelInput: any;
34

35
    ngAfterViewInit(): void {
36
        const intlTelInputInstance = intlTelInput;
17✔
37
        this._intlTelInput = intlTelInputInstance(this._inputElement.nativeElement, this.options);
17✔
38
    }
39

40
    get intlTelInput(): any {
41
        return this._intlTelInput;
1✔
42
    }
43

44
    get phoneNumber(): string {
45
        return this._phoneNumber;
42✔
46
    }
47

48
    set phoneNumber(value: string) {
49
        if (!!value) {
3✔
50
            this._intlTelInput.setNumber(value);
3✔
51
        }
52
        this._phoneNumber = value;
3✔
53
        this.i18nizePhoneNumber();
3✔
54
    }
55

56
    i18nizePhoneNumber(): void {
57
        this.E164PhoneNumber = null;
4✔
58
        if (this._intlTelInput.isValidNumber()) {
4✔
59
            this.E164PhoneNumber = this._intlTelInput.getNumber();
4✔
60
        }
61
        this.E164PhoneNumberChange.emit(this.E164PhoneNumber);
4✔
62
    }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc