I have a function in typescript that receives a json value from my webapi, and I need to pass this result to a select in html ...
Service:
teste: teste[];
public getNomes(type: string, formGroup: FormGroup) {
let params: HttpParams = undefined;
params = new HttpParams().set('type', type);
switch (type) {
case "teste":
params = params.set('cod', formGroup.controls['codigoCliente'].value);
this.retornaNomeApi(API + '/Pesquisa/SelectPesquisa', params).subscribe(nome => {this.teste = nome.result});
}
}
HTML:
<select class="form-control" name="pedido">
<option selected>Selecione...</option>
<option *ngFor="let testes of teste">{{testes.cod}} - {{testes.nome}}</option>
</select>
Thank you in advance: D