I am facing issue, where I cannot set team's club to [selected] option with [ngValue]. However, if I'm using [value] and [selected], it set's team's club to the option, but I cannot pass object with [value]
Here is my code:
Using [value] and [selected], which sets team's club to [selected] option, but I cannot pass object to the [value]
<select
*ngIf="isEditing"
name="club"
#club="ngModel"
[ngModel]="team?.club">
Change club's logo
<option
*ngFor="let item of premierLeagueTeams"
[value]="item"
[selected]="item === team?.club">
{{ item.club }}
</option>
</select>
Using [ngValue], but options field doesn't have team's club when I start editing.
<select
*ngIf="isEditing"
class="team-club-change"
name="club"
#club="ngModel"
[ngModel]="team?.club.clubName"
(change)="changeTeam(club.value)">
Change club's logo
<option
*ngFor="let item of premierLeagueTeams"
[ngValue]="item">
{{ item.clubName }}
</option>
</select>
interfaces
export interface Team {
name: string,
club: Club,
id: number
}
export interface Club {
clubName: string,
logoURL: string,
venue: string,
city: string
}