<form [formGroup]="formularioedit" #formRegister="ngForm" (ngSubmit)=" updateMensaje()">
<select formControlName="subareas" *ngIf="!nomostrarsubarea" style="width:120px">
<option *ngFor="let opciones of subareas" [value]="opciones.id" >
{{opciones.NameSubArea}}
</option>
</select>
<select formControlName="temas" *ngIf="!nomostrartema" (change)="capturarTema()" style="width:120px">
<option *ngFor="let temario of temas" [value]="temario.id" >
{temario.NameTema}}</option>
</select>
</form>
I need to assign a default value in the list, the problem is that I have 70 topics registered, and after a few seconds this will change it to the first in the list
ejercicio: EjercicioInterface = {
exerciseTitle: '',
exercise: '',
answers: '',
idArea: '',
subarea: '',
punctuation: 0,
correctAnswer: '',
date: null,
tema: '',
nivel: '',
universidad: '',
fecha: null,
alternativa1: '',
alternativa2: '',
alternativa3: '',
alternativa4: '',
alternativa5: '',
admision: '',
identificador: '',
};
The problem I notice is that I have the 70 mixed between different areas, the idea is that this id already feels stored, and compare it and then assign it by value as a default.
const params = this.activatedRoute.snapshot.params;
if (params) {
this.ejercicioService.getEjercicio(params.id).subscribe(res => {
this.ejercicio = res;
console.log("Ejercicio: " + this.ejercicio);
console.log("ID TEMA: " + this.ejercicio.tema);
this.getAreas();
this.getSubAreas();
if (this.ejercicio.idArea == "2") {
this.getTemasFisica();
this.nomostrarsubarea = true;
this.nomostrartema = false;
}
if (this.ejercicio.idArea != "2") {
if (this.ejercicio.subarea === '15') {
this.nomostrartema = true;
} else {
this.nomostrartema = false;
this.gettemas();
}
// console.log("Distinto de 2");
this.gettemas();
}
if (this.ejercicio.idArea === '3') {
this.nomostrartema = true;
this.nomostrarsubarea = false;
//console.log("presionaste algo distinto a fisica");
//this.getSubAreas();
}
console.log("Tema Actual: " + this.ejercicio.tema);
this.formularioedit.controls['subareas'].setValue(this.ejercicio.subarea);
this.formularioedit.controls['temas'].setValue(this.ejercicio.tema);
});
}
