@ABCquestion

Как перенести фокус на елемент количество которые определяется в цикле?

как поправить?
public shiftfocus(index: number): void  {
    const indexKey = `${index}`;
    if(this.compoundStringFormGroup?.get(indexKey).value.length === 0){
     let previndexKey = `${index - 1}`;
      @ViewChild(previndexKey) elindexKey: ElementRef;
      elindexKey.focus()
    }
  }


<ng-template #widgetContent>
    <div class="compound-string-container">
      <div *ngIf="compoundStringFormGroup" class="compound-string-wrapper">
        <ng-container *ngFor="let part of numOfStringParts; let i=index">
          <gas-input
            [attr.id]="i"
            class="compound-string"
            [formControl]="getPartControlByIndex(i)"
            [nativeDisabled]="!!field?.readonly"
            [required]="field?.readonly ? false : !!field?.mandatory"
            (keydown.backspace)="shiftfocus(i)"
          ></gas-input>
        </ng-container>
      </div>
    </div>
  </ng-template>
  • Вопрос задан
  • 9 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы