I can't seem to figure out what I am doing wrong. I am trying to get the value of a dropdown to be selected in my form. Here is the template-driven form I am using:
<select class="form-control" id="role"
required
[(ngModel)]="user.role" name="role"
#role="ngModel">
<option *ngFor="let user_role of user_roles" [ngValue]="user_role">{{user_role.display_name}}</option>
</select>
this.user = new User(user_details.name,user_details.email,user_details.roles[0],user_details.is_confirmed,'','',user_details.image);
this is user_details.roles[0] :
[
{
"id": 1,
"name": "admin",
"display": "Administrator",
"pivot": {
"user_id": 6,
"role_id": 1
}
}
]
I can't figure out the issue as to why the value is not being selected. After investigating, I suspect that it is because of the "pivot" object inside the [0] key. I tried removing "pivot" and it worked fine.