I populate the first drop-down menu using *ngFor, then send the value to a PHP API to get the list of students in the class selected. I do recieve the information, as displayed in the console.log, but cannot seem to get the names listed in the second drop-down menu, which is the aim!
<form (submit)="confirmClasse($event, $classes)">
<ion-list ng-app="myApp">
<ion-select type="text" id="classe" name="classe" (ionChange)="onSelectChange($event)"
placeholder="Selectionnez la classe" class="inputBox" #classe>
<ion-select-option *ngFor="let classe of classes; let i = index" [value]="">{{ classe.classe }}
</ion-select-option>
</ion-select>
<br>
</ion-list>
</form>
<form (submit)="createRdv($event)">
<ion-list>
<ion-select type="text" id="names" name="names" class="inputBox" #names>
<ion-select-option *ngFor="let name of names" [value]="">{{ name.nom }}</ion-select-option>
</ion-select>
<br>
Is it a problem with my HTML? Or am I missing something more important?
Iām still not seeing the part where names gets modified. What Iām specifically looking for is whether you are (a) assigning a different array to names or (b) poking around inside names changing the things inside it without actually making a new array.
Donāt do (b) - it deceives change detection into failing to perceive that anything has changed with names. The setTimeout is unneeded and unwanted. The detectChanges will, I believe, become necessary, but only if names is actually being changed (not just its contents).
Apologies if Iām saying the same thing over and over, but:
Your second ngFor is looping over a property called names. Somewhere, that property is assigned to: this.names = .... Such an assignment must happen every time a new class is selected.
I wouldnāt think queryParams would emit until you navigate somewhere else with the router, so I would not try to use it for this purpose.
One of my rules is āalways separate creation of and subscription to Observablesā. rdvListStudents breaks this rule by doing both. I would refactor it thusly:
Thanks for your help. Iāve had a play with your code but honestly, it seems a little advanced for me - Iāve no idea how to impliment it into my code. Iāll take another look in the morning and see if things become a little clearer. Thanks again.