InfomediaLtd / angular2-materialize

Angular 2 support for Materialize CSS framework.
https://infomedialtd.github.io/angular2-materialize/
MIT License
407 stars 140 forks source link

Select doesn't respond to [selected] tag #360

Closed PetarRing closed 7 years ago

PetarRing commented 7 years ago

The select box I have, won't change the selected option.

My first attempt was: [selected]="category.value == user.userCategory.value""

but it doesn't work.

I tried removing the <option value="" disabled selected>Choose your option</option> too but neither did it work.

`

perm_identity <select [(ngModel)]="user.userCategory" name="userCategory" materialize="material_select" [materializeSelectOptions]="userCategories" required="">

            <option *ngFor="let category of userCategories" [value]="category.value" [selected]="category.value == user.userCategory.value">{{category.name}}</option>
          </select>
    <label>User category</label>
  </div>`

Here seen as a picture: image

The select-box works besides this, but when I try to initially select an option based on a user that should be edited, it won't change to category the user has.

PetarRing commented 7 years ago

[SOLVED]

changed line: [value]="option.value" to [value]="option"