ngx-intl-tel-input 无法提供自定义 tabindex



我使用ngx-intl-tel输入作为一个单独的组件,并尝试提供自定义tabindex,但不带到country框字段输入框字段实际上我怎样才能使它成为可能?

<ngx-intl-tel-input *ngIf="!tooltip && type == 'phone' && !showPasswordIcon" [inputId]="fcn ? fcn : 'mobileNumber'" cssClass="form-control input-md" class="phone-box" [enablePlaceholder]="enablePlaceholder" [selectedCountryISO]="CountryISO.Australia" [maxLength]="15" [separateDialCode]="true" [formControl]="form.controls[fcn]" [phoneValidation]="true" container="body" (paste)="onlyNumbers($event)" (drop)="onlyNumbers($event)" triggers="manual" #inputContainer customPlaceholder="Mobile number"> </ngx-intl-tel-input>

您可以考虑创建一个指令,帮助您在所需的输入元素上添加tabIndex

@Directive({
selector: '[addTabIndex]',
})
export class AddTabIndexDirective {
@Input() addTabIndex;
@Input() targetElement = 'input';
constructor(private el: ElementRef, private render: Renderer2) {}
ngAfterViewInit() {
const input = this.el.nativeElement.querySelector(this.targetElement);
if (input && this.addTabIndex) {
this.render.setAttribute(input, 'tabindex', this.addTabIndex);
}
}
}

用法

<ngx-intl-tel-input addTabIndex="2"><ngx-intl-tel-input/>

堆叠闪电

最新更新