I'm getting roles from rest-api in my component like:
this.userService.getRoles().subscribe(data => this.roles = data);
Then I'm trying to use it in my template as below:
<select name="role" [(ngModel)]="user.role">
<option *ngFor="let role of roles" [ngValue]="role">{{role.name}}</option>
</select>
But it's not working, output for {{roles | json}}, so everything is fine with them, the problem is select doesn't work.
[{"id":1, "name":"user"}, {"id":2, "name":"admin"}]
user = { role: 'user'}