Как отключить флаг в ngx-intl-tel-input lib?

как отключить флаг в библиотеке «ngx-intl-tel-input», я отключаю поле ввода в форме, имеющее ngx-intl-tel-input, но не отключаю флаг. См. исправленную проблему "https://github.com/webcat12345/ngx-intl-tel-input/issues/205"


person Community    schedule 27.09.2019    source источник


Ответы (2)


Эта проблема была исправлена ​​в последних выпусках. Чтобы отключить элемент управления, включая раскрывающийся список стран:

phoneForm = new FormGroup({
   phone: new FormControl({
    value: undefined,
    disabled: true
  }, [Validators.required])
});

or

this.phoneForm.controls['phone'].disable();
person pasevin    schedule 08.06.2020

Я нашел хак. Возьмите ссылку <ngx-mat-intl-tel-input> и отключите кнопку внутри нее. Проверьте код ниже.

HTML:

<ngx-mat-intl-tel-input
    [preferredCountries]="['us']"
    [enablePlaceholder]="true"
    [enableSearch]="true"
    format="national"
    name="phone"
    placeholder="Phone Number"
    formControlName="phone"
    #phoneField
  ></ngx-mat-intl-tel-input>

Компонент ТС:

 @ViewChild('phoneField')
  public phoneField;

public ngAfterViewChecked() {
    // disabling country selection button
      try {
        this.phoneField.elRef.nativeElement.firstChild.children[0].disabled = 'true';
      } catch (e) {
        // ignore this
      }
  }

Наслаждаться :)

person Sajal    schedule 08.04.2021