Select options don't populate on reload

Discussão em 'Angular' iniciado por Brian, Abril 10, 2025.

  1. Brian

    Brian Guest

    Angular application trying to populate the options in a select with results from an API call:

    <select class="select input input-bordered" formControlName="student" (change)="onStudentChange($event)" >
    <option *ngFor="let student of students" value="{{student._id}}">{{ student.name }}</option>
    </select>


    ngOnInit:

    ngOnInit(): void {
    this.userService.getStudentsByUser(this.authService.currentUserSig()?._id!).subscribe((response) => {
    this.students = response;
    });
    }


    What am I missing here? While debugging locally and I save the html file it then magically populates, but on refresh it goes away.

    Continue reading...

Compartilhe esta Página