1

I have a select element:

 <select [id]="item.value.controlName" [(ngModel)]="item.value.outputVarianteValue"
            (focus)="focusControl(item.value.controlName)"                  
       <option *ngFor="let c of item.value.produkte" [ngValue]="c.name">{{c.wert}}</option>
 </select>

I rebuild my GUI programmaticaly and want to reset the focus to the element selected before (focusedcontrol)

  setTimeout(() => {
              const element = this.ngrenderer.selectRootElement('#' + this.focusedControl);
              console.log('set root focus: ', this.focusedControl, element)
              element.focus();
            }, 0)

This works without a problem on normal inputs but not on the selects. After callling ngrenderer.selectRootElement(#myselect) my select field is empty.

daniel
  • 34,281
  • 39
  • 104
  • 158

1 Answers1

0

answer is here:

Renderer multiple selectRootElement Issue

If you want to preserve content then use the second boolean parameter to true, like this: (using Angular 6+)

daniel
  • 34,281
  • 39
  • 104
  • 158