I have 2 objects in my project: a company
and an user
. I have a form where the user can update his profile. One of the things he can update is the country. Now to show the countries I use a dropdown list.
I want to set the selected
attribute in the option where the name
of the country
is equal to the actual country
of the user
. (country.name==user.country
)
This is what I have tried but It doesn't seem to work.
<select>
<option *ngFor="#c of countries" [ngStyle]="setStyles()" [ngValue]="c">{{c.name}}</option>
</select>
setStyles(){
let styles;
if (this.companies[i].name == this.user.country ) {
styles = {
'selected'
}
return styles;
}