A Datalist element of html5 connected to a rest service is not displayed on the first click, it requires a second click

0

I have a datalist who gets the options of a rest service. At first the datalist does not have the options, it is empty. When you click on the element (1st click - focus) you get the values for the options but the datalist is not displayed, it is necessary to make another click (2nd click) to open the datalist. Once I have the options, it works normally.

Is there a way to display ( open ) a datalist by code, after loading the options received in the rest.?

UPDATEEST

I add the relevant portion of the code.

The data is loaded correctly in " uas " (shows the spiner, etc) but does not display the datalist. It is necessary to make a 2nd click to display it.

<div class="threecol">
    <label for="ua">Seleccione</label> <input
        type="text" class="form-control" id="ua" name="ua"
        [(ngModel)]="model.ua" #ua="ngModel"
        (focus)="recuperarDatos()"/>  //trae las opciones
    <datalist id="uasId">
        <option *ngFor="let ua of uas" [ngValue]="ua.id">{{ua.id}}
            {{ua.descripcion}}</option>
    </datalist>
</div>

.ts 

    class example {
    ..
    ..
    recuperarDatos(){
        ...
        this.uas = obtenerDatosByRest();  //opciones

        //aca obtener el datalist y desplegarlo
    }
}
    
asked by cairelxc 13.07.2018 в 16:48
source

0 answers