I have a select whose options
are generated for the data returned by an HTTP request in the ngOninit
hook.
it looks like this:
ngOnInit() {
this.documentosService.buscaParametros(this.request).subscribe(res => {
this.tipoDocumento = res["general"];
}
this is the HTML code:
<select class="form-control pv-0" formControlName="tipoFactura" name="tipoFactura">
<option *ngFor="let documento of tipoDocumento">
{{documento.par_deslargo01}}</option>
</select>
If it wasn't generated dynamically I could just write the selected
directive to the first option
element, but in this case I don't know how to achieve it. I need that when the component first load the first option is selected.
How could achieve this? Thanks.